Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker dev env #5583

Merged
merged 30 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8c27a31
add docker development environment
maxgrossman Feb 27, 2023
ff9d8dd
newlines
maxgrossman Feb 28, 2023
4a63997
do not make build dep of up. this way build can be separate way to ha…
maxgrossman Feb 28, 2023
35f9578
just mount hoot-ui-2x dir
maxgrossman Feb 28, 2023
ffcd681
removing extra lines
maxgrossman Feb 28, 2023
92f4a4a
adding missing and fixing incorrect volumes
maxgrossman Mar 6, 2023
00aadc2
let us attach a remote debugger for services
maxgrossman Mar 6, 2023
d34649a
only copy files/war when we build them
maxgrossman Mar 6, 2023
1597bef
add db_host_osmapi to DatabaseConfigLocal target
maxgrossman Mar 9, 2023
a146a0a
correct osmapi host name
maxgrossman Mar 9, 2023
68b5d30
handle older versions of docker/docker-compose
brianhatchl Mar 9, 2023
6a3454a
git ignore .npm
brianhatchl Mar 9, 2023
f011038
update hoot-ui-2x submodule
maxgrossman Mar 9, 2023
eba2ea6
add missing new line
maxgrossman Mar 9, 2023
d365fc8
Merge remote-tracking branch 'origin/master' into docker_dev_env
brianhatchl Mar 29, 2023
19abb86
Updates to docker PR to work in fresh git repo clone (#5614)
brianhatchl Mar 31, 2023
388e63c
restore FORCE to always attempt VersionDefines.h rebuild
brianhatchl Apr 13, 2023
335e4a9
this seems to be causing ./HOOT_VERSION_GEN to loop
brianhatchl Apr 13, 2023
f062ae9
don't need this
brianhatchl Apr 13, 2023
2204e2d
revert changes to see if it affects 'make archive'
brianhatchl Apr 13, 2023
5a6d332
try .PHONE instead of FORCE
brianhatchl Apr 14, 2023
e0ad41b
Merge remote-tracking branch 'origin/master' into docker_dev_env
brianhatchl Apr 28, 2023
7ced311
Merge remote-tracking branch 'origin/master' into docker_dev_env
brianhatchl Jun 16, 2023
89553be
Submodule hoot-ui-2x 521e79585..d2bbe9541:
brianhatchl Jun 16, 2023
5de4d6c
wip: add some docker command refs
brianhatchl Jun 19, 2023
405490c
need to run configure each time because generated Makefile can get stale
brianhatchl Jun 19, 2023
c2e8e00
need to call this too when core builds services
brianhatchl Jun 21, 2023
f06d3bb
Move versions out to .env file and expose in docker-compose.yml (#5675)
brianhatchl Sep 26, 2023
2504791
Merge remote-tracking branch 'origin/master' into docker_dev_env
brianhatchl Sep 26, 2023
974780c
Submodule hoot-ui-2x 7e0099d18...804b1502f:
brianhatchl Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .env_versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
POSTGRESQL_VERSION=13
GLPK_VERSION=4.64
LIBOAUTHCPP_VERSION=0.1.0
LIBPHONENUMBER_VERSION=8.12.39
LIBPOSTAL_VERSION=1.1
NODE_VERSION=14.16.1
NPM_VERSION=6.14.12
V8_VERSION=8.4.371.19
STXXL_VERSION=1.3.1
ARMADILLO_VERSION=10.8.2
GDAL_VERSION=3.2.3
GEOS_VERSION=3.9.3
LIBGEOTIFF_VERSION=1.6.0
PROJ_VERSION=7.2.1
DEVTOOLSET_VERSION=8
JDK_VERSION=1.8.0
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,11 @@ config.rpath
0
tbs/0
.DS_Store
.ccache
.ccache/**/*
.m2
.env
hoot.env
.bash_history
.config
.npm
32 changes: 32 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Docker development environment cheat sheet


To start the containers
>make -f Makefile.docker up


To stop the containers
>make -f Makefile.docker down


To tail tomcat logs
>docker-compose logs --follow core-services


To bash to the core-services container
>docker-compose exec core-services bash


To force clean/build on container start, modify hoot.env _e.g._
```
HOOT_CLEAN=0
HOOT_BUILD_CORE=1
HOOT_BUILD_HOOT_SERVICES=1
HOOT_BUILD_JS_SCHEMA=0
HOOT_BUILD_TRANSLATION_SERVER=0
HOOT_BUILD_NODE_EXPORT_SERVER=0
HOOT_SERVICES_HOST=core-services
HOOT_SERVICES_PORT=8080
HOOT_NPM_INSTALL=0
```
to set any properties from 0 to 1 and then stop/start the containers.
66 changes: 66 additions & 0 deletions Makefile.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
UID=$(shell id -u)
GID=$(shell id -g)

DOCKER_VERSION := $(shell docker --version 2>/dev/null)

ifndef DOCKER_VERSION
$(error "command docker is not available, please install Docker")
endif

# The "new" version integrates compose in the docker command.
# It also fixes a bug with stopping log output when the "--follow" option is set
COMPOSE_COMMAND=docker compose

DOCKER_COMPOSE_NEW := $(shell docker compose version 2>/dev/null)
ifndef DOCKER_COMPOSE_NEW
DOCKER_COMPOSE_OLD := $(shell docker-compose --version 2>/dev/null)
ifdef DOCKER_COMPOSE_OLD
COMPOSE_COMMAND = docker-compose
else
$(error "docker compose is not available, please install it")
endif
endif

hoot.env:
cp hoot.env.example hoot.env

.env: hoot-ui-2x/README.md
cp .env_versions .env
mkdir -p bin lib .ccache
echo "HOOT_UID=$(UID)" >> .env
echo "HOOT_GID=$(GID)" >> .env
echo "HOOT_USER=hoot" >> .env
echo "HOOT_GROUP=hoot" >> .env
echo "HOOT_HOME=/var/lib/hootenanny" >> .env

conf/database/DatabaseConfigLocal.sh:
touch conf/database/DatabaseConfigLocal.sh
chmod +x conf/database/DatabaseConfigLocal.sh
echo "#!/bin/bash;" >> conf/database/DatabaseConfigLocal.sh
echo "set -euo pipefail;" >> conf/database/DatabaseConfigLocal.sh
echo "export DB_HOST=postgres" >> conf/database/DatabaseConfigLocal.sh
echo "export DB_HOST_OSMAPI=postgres" >> conf/database/DatabaseConfigLocal.sh

hoot-ui-2x/README.md:
git submodule update --init

build: .env hoot.env conf/database/DatabaseConfigLocal.sh hoot-ui-2x/README.md
DOCKER_BUILDKIT=1 $(COMPOSE_COMMAND) build --no-cache

up: .env hoot.env conf/database/DatabaseConfigLocal.sh hoot-ui-2x/README.md
DOCKER_BUILDKIT=1 $(COMPOSE_COMMAND) up -d

down: .env hoot.env
DOCKER_BUILDKIT=1 $(COMPOSE_COMMAND) down

distclean: .env hoot.env
DOCKER_BUILDKIT=1 $(COMPOSE_COMMAND) down --volumes --rmi all
rm -fr .ccache lib bin \
.env hoot.env hoot-ui-2x/node_modules \
conf/database/DatabaseConfigLocal.sh

PHONY: \
build \
distclean \
down \
up
8 changes: 3 additions & 5 deletions Makefile.hoot
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ endif

SHELL=/bin/bash

.PHONY: clean-ccache
.PHONY: clean-ccache HOOT_VERSION_FILE

# This list is for manually rebuilding the schema files. The files have been commited to the main GitHub repo
SCHEMA_FILES= translations/tds71_schema.js translations/tds70_schema.js translations/tds61_schema.js translations/tds40_schema.js translations/mgcp_schema.js translations/mgcp_thematic_schema.js translations/ggdm30_schema.js translations/tds71_thematic_schema.js translations/tds71_full_schema.js translations/tds61_full_schema.js translations/tds70_full_schema.js translations/tds40_full_schema.js translations/ggdm30_full_schema.js translations/etds71_rules.js translations/etds70_rules.js translations/etds61_rules.js translations/etds40_rules.js translations/emgcp_rules.js translations/eggdm30_rules.js translations/etds71_osm_rules.js translations/etds61_osm_rules.js translations/etds40_osm_rules.js translations/emgcp_osm_rules.js translations/eggdm30_osm_rules.js translations/etds70_osm_rules.js
Expand Down Expand Up @@ -404,11 +404,9 @@ else
echo "UI tests must specify both --with-services and --with-uitests."
endif

HOOT_VERSION_FILE: hoot-core/src/main/cpp/hoot/core/info/VersionDefines.h
-include HOOT_VERSION_FILE

hoot-core/src/main/cpp/hoot/core/info/VersionDefines.h:
Comment on lines -407 to -410
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bmarchant I made this change because we need HOOT_VERSION_GEN to always run. I had whacked a FORCE target that I didn't consider the impact of here cbbaa64 that I think necessitated your change that I'm now fixing with .PHONY.

For some reason the make archive step was failing in some iterations where I tried to restore FORCE and in other iterations it was leading to an infinite loop calling HOOT_VERSION_GEN.

This configuration seems to work in forcing the regeneration of VersionDefines.h on every build without the above defect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will regenerating VersionDefines.h every time make is run cause a major rebuild? If so, this would slow down compilation during development of Hootenanny outside of docker containers. Maybe somewhere in the docker container the change could be made using sed or something like that.

Copy link
Contributor

@brianhatchl brianhatchl Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the older FORCE target this should have also been the case. But the HOOT_VERSION_GEN script only regenerates VersionDefines.h if the version has actually changed so I think it should be ok. If it has changed that would necessitate a core rebuild of the three cpp classes that include it.

HOOT_VERSION_FILE:
$(SHELL_PATH) ./HOOT_VERSION_GEN;
-include HOOT_VERSION_FILE

rebuild-db:
scripts/database/DeleteAllTables.sh
Expand Down
4 changes: 2 additions & 2 deletions VagrantProvisionCentOS7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ fi

if ! grep --quiet "export JAVA_HOME" ~/.bash_profile; then
echo "Adding Java home to profile..."
echo "export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk" >> ~/.bash_profile
echo "export JAVA_HOME=/usr/lib/jvm/java-$JDK_VERSION-openjdk" >> ~/.bash_profile
echo "export PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bash_profile
source ~/.bash_profile
else
sed -i '/^export JAVA_HOME=.*/c\export JAVA_HOME=\/usr\/lib\/jvm\/java-1.8.0-openjdk' ~/.bash_profile
sed -i '/^export JAVA_HOME=.*/c\export JAVA_HOME=\/usr\/lib\/jvm\/java-\$JDK_VERSION-openjdk' ~/.bash_profile
fi

# Update the GDAL_DATA folder in ~/.bash_profile
Expand Down
2 changes: 1 addition & 1 deletion VagrantProvisionCentOS7Deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ sudo yum -y install \
opencv-devel \
opencv-python \
osmosis \
java-1.8.0-openjdk \
java-${JDK_VERSION}-openjdk \
perl-XML-LibXML \
parallel \
postgresql${POSTGRESQL_VERSION_DOTLESS} \
Expand Down
10 changes: 1 addition & 9 deletions VagrantProvisionVars.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env bash

export JDK_VERSION=1.8.0_161
export JDK_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz
export JDK_TAR=jdk-8u161-linux-x64.tar.gz
export JDK_MD5=99051574a0d90871ed24a91a5d321ed2
export JDK_VERSION=1.8.0

# Hoot deps library versions
export GLPK_VERSION=4.64
Expand All @@ -27,10 +24,5 @@ export PROJ_VERSION=7.2.1
export POSTGRESQL_VERSION=13
export POSTGRESQL_VERSION_DOTLESS="$(echo "$POSTGRESQL_VERSION" | awk '{ gsub(/\./, ""); print substr($0, 1, 2) }')"

# FGDB 1.5 is required to compile using g++ >= 5.1
# https://trac.osgeo.org/gdal/wiki/FileGDB#HowtodealwithGCC5.1C11ABIonLinux
export FGDB_VERSION=1.5.1
export FGDB_URL=https://github.com/Esri/file-geodatabase-api/raw/master/FileGDB_API_${FGDB_VERSION}/

# Devtoolset
export DEVTOOLSET_VERSION=8
74 changes: 74 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: "3.7"
x-args: &default-args
hoot_uid: "${HOOT_UID}"
hoot_gid: "${HOOT_GID}"
hoot_user: "${HOOT_USER}"
hoot_group: "${HOOT_GROUP}"
hoot_home: "${HOOT_HOME}"
postgresql_version: "${POSTGRESQL_VERSION}"
glpk_version: "${GLPK_VERSION}"
liboauthcpp_version: "${LIBOAUTHCPP_VERSION}"
libphonenumber_version: "${LIBPHONENUMBER_VERSION}"
libpostal_version: "${LIBPOSTAL_VERSION}"
node_version: "${NODE_VERSION}"
npm_version: "${NPM_VERSION}"
v8_version: "${V8_VERSION}"
stxxl_version: "${STXXL_VERSION}"
armadillo_version: "${ARMADILLO_VERSION}"
gdal_version: "${GDAL_VERSION}"
geos_version: "${GEOS_VERSION}"
libgeotiff_version: "${LIBGEOTIFF_VERSION}"
proj_version: "${PROJ_VERSION}"
devtoolset_version: "${DEVTOOLSET_VERSION}"
stxxl_version: "${STXXL_VERSION}"
jdk_version: "${JDK_VERSION}"
services:
frontend:
build:
context: .
dockerfile: docker/Dockerfile.frontend
args: *default-args
hostname: frontend
ports:
- 8080:8080
env_file:
- hoot.env
volumes:
- ./hoot-ui-2x:${HOOT_HOME}/hoot-ui-2x:rw
- ./.git/modules/hoot-ui-2x:${HOOT_HOME}/.git/modules/hoot-ui-2x:rw
postgres:
build:
context: .
dockerfile: docker/Dockerfile.postgres
args: *default-args
hostname: postgres
env_file:
- hoot.env
volumes:
- postgres-data:/var/lib/pgsql/${POSTGRESQL_VERSION}/data:rw
core-services:
depends_on:
postgres:
condition: service_healthy
frontend:
condition: service_healthy
build:
context: .
dockerfile: docker/Dockerfile.core-services
args: *default-args
hostname: core-services
env_file:
- hoot.env
ports:
- 8888:8080
- 8094:8094
- 8096:8096
- 8101:8101
- 8000:8585
volumes:
- ./:${HOOT_HOME}:rw
- tomcat8-hoot-services:/var/lib/tomcat8/webapps/hoot-services:rw

volumes:
postgres-data:
tomcat8-hoot-services:
Loading