More extensive documentation is here - invite only for now!
- Docker (18.03.1). I am using the Community Edition, version 18.03.1, which can be downloaded here.
- Docker Compose (1.21.1). NOTE: Docker for Windows/Mac already come with Docker Compose. Linux users will need to download compose separately from here.
You to see which Docker version you have installed by running the following commands:
docker --version
docker-compose --version
Windows users must do the following before cloning
- Give Docker access to drives. Go to Docker > Settings > Shared Drives, and select the drive that you are going to use.
- Change git's autocrlf setting. (This must happen before you clone the repository!) Type:
git config --global core.autocrlf false
- Clone this repository (sidewalk-docker). Run
git clone https://github.com/aileenzeng/sidewalk-docker
. - Clone the Project Sidewalk repository into the
website
folder of this directory. Rungit fetch origin
and check out the593-move-to-docker
branch in SidewalkWebpage - this branch contains a few updates to the config files that are needed to make this project work properly with Docker. - Obtain a database dump. Name it
sidewalk.sql
and place it into theresources
folder. - Run
docker-compose build
in the project's root directory - this is the directory with thedocker-compose.yml
file. This command builds theDockerfile
s for thewebsite
anddb
services. This step can take ~3-4 minutes the first time. - Run
docker-compose up -d db
. You will need to run this twice until the message says 'Starting sidewalkdocker_db_1 ... done
'. - Run the following commands to create the
postgres
user and to restore the database:
docker exec -it sidewalkdocker_db_1 createuser -U sidewalk -s postgres
docker exec -it sidewalkdocker_db_1 createdb -T template0 -U postgres sidewalk
docker exec -it sidewalkdocker_db_1 pg_restore -U postgres -d sidewalk sidewalk.sql
- After the database finishes restoring, run
docker-compose up
. (If this doesn't work, trydocker-compose up --force-recreate
. This takes care of problems related to environment variables) This step can take ~5-10 minutes the first time.
- (Optional: if no changes to ProjectSidewalk) Run
docker-compose build
. - Run
docker-compose up
Assuming all is running smoothly, you expect to see see the following line:
website_1 | (Server started, use Ctrl+D to stop and go back to the console...)
- Use Ctrl+C to exit. (NOTE: Do not use
docker-compose down
)
- Obtain a database dump (EX:
sidewalk.sql
) and place it into theresources
folder. - Run the following commands:
docker-compose up -d db
docker exec -it sidewalkdocker_db_1 createdb -T template0 -U postgres <database-name>
docker exec -it sidewalkdocker_db_1 pg_restore -U postgres -d sidewalk <database-file>
Run the following commands:
docker-compose up -d db
docker exec -it sidewalkdocker_db_1 pg_dump -U sidewalk sidewalk -Fc -f dump.sql
docker cp sidewalkdocker_db_1:/dump.sql /host/path/target/sidewalk.sql
These changes are on the 593-move-to-docker
branch.
Many javax.media
files are missing. For example, javax.media#jai_core;1.1.3!jai_core.jar
is missing from the Maven repository. It is also missing from osgeo. Additionally, downloads.osgeo
no longer seems to be supported. This prevents geotools
dependencies from being downloaded.
These cause problems during sbt compile
and sbt run
. More detailed writeups of these issues are here and here.
To fix this, I had to modify the build.sbt
file in Sidewalk. These changes aren't reflected in this repository since SidewalkWebpage is part of the .gitignore
file. I haven't tried integrating this change into the Sidewalk repository that is on my computer that isn't running on Docker yet.
This is the updated code for build.sbt
:
resolvers ++= Seq(
"geosolutions" at "http://maven.geo-solutions.it/",
"boundlessgeo" at "https://repo.boundlessgeo.com/main/",
"osgeo" at "http://download.osgeo.org/webdav/geotools/"
)
libraryDependencies ++= Seq(
jdbc,
(...etc...)
"javax.media" % "jai_core" % "1.1.3" from "http://maven.geomajas.org/nexus/content/groups/public/javax/media/jai-core/1.1.3",
"javax.media" % "jai_codec" % "1.1.3" from "http://maven.geomajas.org/nexus/content/groups/public/javax/media/jai_codec/1.1.3",
"javax.media" % "jai_imageio" % "1.1" from "http://maven.geomajas.org/nexus/content/groups/public/javax/media/jai_imageio/1.1",
"org.geotools" % "gt-coverage" % "14.3",
"org.geotools" % "gt-epsg-hsql" % "14.3",
"org.geotools" % "gt-geotiff" % "14.3",
"org.geotools" % "gt-main" % "14.3",
"org.geotools" % "gt-referencing" % "14.3" excludeAll(
ExclusionRule(organization = "javax.media"),
ExclusionRule(organization = "jgridshift")
)
).map(_.force())
This line allows the website service to connect with the Postgres database. The location db.default.url
is based off an environment variable that is the docker-compose.yml
file. A more detailed writeup of the initial issue is here.
This is the updated code in application.conf
. This can go below the db.default.url
that already exists for localhost:5432
.
# This is for docker.
# Pulls the from the DOCKER_DB environment variable from the compose file.
db.default.url="jdbc:postgresql://"${?DOCKER_DB}"/sidewalk"