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

self signed cert for upstream frontend dev server #5625

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
67 changes: 67 additions & 0 deletions Makefile.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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
touch .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
echo "POSTGRESQL_VERSION=14" >> .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
58 changes: 58 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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}"
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:
197 changes: 197 additions & 0 deletions docker/Dockerfile.core-services
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
FROM centos:7

ARG hoot_user
ARG hoot_uid
ARG hoot_gid
ARG hoot_group
ARG hoot_shell=/bin/bash
ARG hoot_home

ARG glpk_version=4.64
ARG liboauthcpp_version=0.1.0
ARG libphonenumber_version=8.12.39
ARG libpostal_version=1.1
ARG node_version=14.16.1
ARG npm_version=6.14.12
ARG v8_version=8.4.371.19
ARG stxxl_version=1.3.1
ARG armadillo_version=10.8.2
ARG gdal_version=3.2.3
ARG geos_version=3.9.3
ARG libgeotiff_version=1.6.0
ARG proj_version=7.2.1
ARG devtoolset_version=8
ARG v8_version=8.4.371.19
ARG stxxl_version=1.3.1
ARG postgresql_version=14


ENV HOOT_HOME=$hoot_home

COPY scripts/yum/geoint-repo.sh scripts/yum/hoot-repo.sh scripts/yum/pgdg-repo.sh /tmp

RUN --mount=type=cache,target=/var/cache/yum \
/tmp/geoint-repo.sh && \
/tmp/hoot-repo.sh && \
/tmp/pgdg-repo.sh $postgresql_version && \
yum-config-manager --save \
--setopt=base.repo_gpgcheck=1 \
--setopt=extras.repo_gpgcheck=1 \
--setopt=updates.repo_gpgcheck=1 &> /dev/null && \
yum -y install epel-release centos-release-scl

RUN yum install -y \
armadillo-$armadillo_version \
devtoolset-$devtoolset_version \
devtoolset-$devtoolset_version-libasan-devel \
geos-$geos_version \
geos-devel-$geos_version \
glpk-$glpk_version \
glpk-devel-$glpk_version \
gdal-$gdal_version \
gdal-devel-$gdal_version \
gdal-python-tools-$gdal_version \
google-chrome-stable-$google_chrome_version \
libgeotiff-$libgeotiff_version \
libgeotiff-devel-$libgeotiff_version \
liboauthcpp-$liboauthcpp_version \
liboauthcpp-devel-$liboauthcpp_version \
libphonenumber-$libphonenumber_version \
libphonenumber-devel-$libphonenumber_version \
libpostal-$libpostal_version \
libpostal-data-$libpostal_version \
libpostal-devel-$libpostal_version \
npm-$npm_version \
nodejs-$node_version \
nodejs-devel-$node_version \
nodejs-docs-$node_version \
nodejs-libs-$node_version \
postgresql$postgresql_version \
postgresql$postgresql_version-contrib \
postgresql$postgresql_version-server \
proj-$proj_version \
proj-devel-$proj_version \
stxxl-$stxxl_version \
stxxl-devel-$stxxl_version \
v8-devel-$v8_version

RUN yum -y install \
asciidoc \
autoconf \
autoconf-archive \
automake \
bison \
boost-devel \
bzip2 \
ccache \
cmake \
cppunit-devel \
dblatex \
doxygen \
gcc-c++ \
git \
git-core \
gnuplot \
lcov \
libffi-devel \
libicu-devel \
libpng-devel \
libtool \
liquibase \
maven \
m4 \
mlocate \
opencv \
opencv-core \
opencv-devel \
opencv-python \
osmosis \
java-1.8.0-openjdk \
perl-XML-LibXML \
parallel \
make \
protobuf \
protobuf-compiler \
protobuf-devel \
python \
python-devel \
python3 \
python3-devel \
python3-matplotlib \
python3-pip \
python3-setuptools \
qt5-qtbase \
qt5-qtbase-devel \
qt5-qtbase-postgresql \
qt5-qtwebkit \
qt5-qtwebkit-devel \
readline-devel \
redhat-lsb-core \
sqlite-devel \
swig \
tex-fonts-hebrew \
texlive \
texlive-collection-fontsrecommended \
texlive-collection-langcyrillic \
tomcat8 \
unzip \
vim \
wamerican-insane \
w3m \
wget \
words \
xorg-x11-server-Xvfb \
zip

RUN yum install -y postgresql$postgresql_version-devel && \
alternatives --install /usr/bin/pg_config pgsql-pg_config /usr/pgsql-$postgresql_version/bin/pg_config 500

RUN groupadd --non-unique -g ${hoot_gid} ${hoot_group} && \
useradd -d ${hoot_home} -m -s ${hoot_shell} -u ${hoot_uid} -g ${hoot_gid} ${hoot_user} && \
chmod 0755 ${hoot_home}

ARG tomcat_config=/etc/tomcat8
ARG tomcat_logs=/var/log/tomcat8

# vars needed for core entrypoint
ENV DEVTOOLSET_VERSION=$devtoolset_version
ENV HOOT_USER=$hoot_user
ENV PG_MAJOR_VERSION=$postgresql_version
ENV PATH=$PATH:/usr/pgsql-$postgresql_version/bin
ENV MANPATH=/opt/rh/devtoolset-$DEVTOOLSET_VERSION/root/usr/share/
ENV TOMCAT_CONFIG=$tomcat_config
ENV TOMCAT8_HOME=/var/lib/tomcat8
ENV TOMCAT_SERVER=$tomcat_config/server.xml

# services configuration files.
RUN echo -e '\
export GDAL_DATA=$GDAL_DATA\n\
export HOOT_HOME=$HOOT_HOME\n\
export HOOT_WORKING_NAME=hootenanny\n\
export JAVA_HOME=$JRE_HOME\n\
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:$JAVA_HOME/lib/amd64/server:$HOOT_HOME/lib\n\
export PATH=$HOOT_HOME/bin:$PATH\n\
export JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8585,server=y,suspend=n"\n'\
>> $tomcat_config/conf.d/hoot.conf

RUN install -d -m 0775 $tomcat_logs
RUN echo '\n\
Please login to the host to view the logs:\n\
sudo journalctl -u tomcat8\n\
EOF\n'\ >> $tomcat_logs/catalina.out

RUN chown $hoot_user:$hoot_user $tomcat_logs/catalina.out

COPY docker/scripts/tomcat_configure.sh /tmp
RUN /tmp/tomcat_configure.sh && rm -f /tmp/tomcat_configure.sh

# let hoot user execute tomcat8 commands
RUN usermod -a -G tomcat $hoot_user

COPY docker/scripts/core-services-entrypoint.sh /docker-entrypoint.sh
COPY docker/scripts/core-services-healthcheck.sh /docker-healthcheck.sh

WORKDIR ${hoot_home}
USER ${hoot_user}
ENTRYPOINT /docker-entrypoint.sh
HEALTHCHECK --interval=15s --start-period=1m CMD ["/docker-healthcheck.sh"]
49 changes: 49 additions & 0 deletions docker/Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM centos:7

ARG hoot_user
ARG hoot_uid
ARG hoot_gid
ARG hoot_group
ARG hoot_shell=/bin/bash
ARG hoot_home
ARG node_version=14

ENV HOOT_HOME=$hoot_home

COPY scripts/node/nodesource-repo.sh scripts/yum/hoot-repo.sh /tmp/

RUN --mount=type=cache,target=/var/cache/yum \
/tmp/nodesource-repo.sh $node_version && \
/tmp/hoot-repo.sh && \
yum-config-manager --save \
--setopt=base.repo_gpgcheck=1 \
--setopt=extras.repo_gpgcheck=1 \
--setopt=updates.repo_gpgcheck=1 &> /dev/null && \
yum makecache -y && \
yum -q -y install epel-release && \
yum -y install \
bzip2 \
git \
git-core \
nodejs-devel yarn openssl \
google-chrome-stable-91.0.4472.114 && \
yum -q -y clean all && rm -f /tmp*.sh

RUN groupadd --non-unique -g ${hoot_gid} ${hoot_group} && \
useradd -d ${hoot_home} -m -s ${hoot_shell} -u ${hoot_uid} -g ${hoot_gid} ${hoot_user} && \
chmod 0755 ${hoot_home}

COPY docker/scripts/frontend-entrypoint.sh /docker-entrypoint.sh
COPY docker/scripts/frontend-healthcheck.sh /docker-healthcheck.sh

# development server needs to use https for oauth2
RUN openssl req \
-new -newkey rsa:2048 \
-days 365 -nodes -x509 \
-subj "/C=US/ST=New York/L=New York/O=Fake/OU=Fake Department/CN=localhost" \
-keyout ${hoot_home}/server.key -out ${hoot_home}/server.crt

USER ${hoot_user}
WORKDIR ${hoot_home}/hoot-ui-2x
ENTRYPOINT /docker-entrypoint.sh
HEALTHCHECK --interval=15s --start-period=1m CMD ["/docker-healthcheck.sh"]
Loading