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

Updates for production #279

Merged
merged 16 commits into from
Mar 19, 2024
Merged
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ images/data/
data/
images/.env
images/tiler.yml
values.dev.yaml
values.dev.yaml
secrets
tegola
15 changes: 15 additions & 0 deletions compose/tiler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:
tiler:
image: ohm-tiler-server:v1
build:
context: ../images/tiler-server
dockerfile: Dockerfile
volumes:
- ../data/tiler-server-data:/mnt/data
- ../images/tiler-server:/app
ports:
- "9090:9090"
env_file:
- ../envs/.env.tiler.example
restart: always
12 changes: 6 additions & 6 deletions images/docker-compose.yml → compose/web.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
version: '3.4'
version: '3.8'
services:
db:
platform: linux/amd64
image: osmseed-db:v1
build:
context: ../images/db
context: ./../images/db
dockerfile: Dockerfile
ports:
- '5432:5432'
volumes:
- ./data/db-data:/var/lib/postgresql/data
env_file:
- ./.env.example
- ./.env.web.example
web:
image: osmseed-web:v1
build:
context: ./web
context: ./../images/web
dockerfile: Dockerfile
ports:
- '80:80'
env_file:
- ./.env.example
- ./.env.web.example
####### Enable for development mode
# volumes:
# - ./../../ohm-website:/var/www
# - ./../../ohm-website:/var/www
23 changes: 23 additions & 0 deletions envs/.env.tiler.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#######################################
# Environment variables for tiler database
#######################################
POSTGRES_HOST=host.docker.internal
POSTGRES_DB=tiler-osm
POSTGRES_USER=postgres
POSTGRES_PASSWORD=1234
POSTGRES_PORT=5432
POSTGRES_DB_MAX_CONNECTIONS=200

# #######################################
# tiler-serve env variables,
# #######################################
TILER_SERVER_PORT=9090
TILER_CACHE_BASEPATH=/mnt/data
TILER_CACHE_MAX_ZOOM=22
TILER_CACHE_TYPE=file
TILER_CACHE_TYPE=file
TILER_CACHE_BUCKET=osmseed-staging
TILER_CACHE_BASEPATH=tegola
TILER_CACHE_REGION=us-east-1
TILER_CACHE_AWS_ACCESS_KEY_ID=...
TILER_CACHE_AWS_SECRET_ACCESS_KEY=...
7 changes: 7 additions & 0 deletions envs/.env.web.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_DB=openstreetmap
POSTGRES_PASSWORD=abcd
POSTGRES_USER=postgres
POSTGRES_PORT=5432
POSTGRES_HOST=host.docker.internal
SERVER_URL=localhost
SERVER_PROTOCOL=http
56 changes: 19 additions & 37 deletions images/tiler-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,29 @@
FROM golang:1.14.1-alpine3.11 AS build
ENV VERSION="v0.8.1"
RUN apk update
FROM gospatial/tegola:v0.19.0

RUN apk add musl-dev=1.1.24-r3 \
gcc=9.3.0-r0 \
bash \
git \
postgresql \
postgresql-contrib

RUN mkdir -p /go/src/github.com/go-spatial/tegola
RUN git clone https://github.com/go-spatial/tegola.git /go/src/github.com/go-spatial/tegola
RUN cd /go/src/github.com/go-spatial/tegola && git checkout v0.13.0
RUN cd /go/src/github.com/go-spatial/tegola/cmd/tegola \
&& go build -gcflags "-N -l" -o /opt/tegola \
&& chmod a+x /opt/tegola
RUN ln -s /opt/tegola /usr/bin/tegola

RUN apk add --update \
python \
py-pip \
py-cffi \
py-cryptography \
&& pip install --upgrade pip \
&& apk add --virtual build-deps \
RUN apk --no-cache add \
gcc \
libffi-dev \
python-dev \
python3 \
py3-pip \
py3-cffi \
py3-cryptography \
linux-headers \
musl-dev \
openssl-dev
openssl-dev \
bash \
git \
postgresql-client \
coreutils \
jq

# Install aws-cli
RUN pip3 install awscli
RUN pip install --upgrade pip && pip3 install awscli mercantile

RUN pip3 install mercantile \
&& apk del build-deps \
&& rm -rf /var/cache/apk/* \
&& apk --purge -v del py-pip
# Cleanup to reduce image size
RUN rm -rf /var/cache/apk/* \
&& apk del py3-pip

RUN apk add --update coreutils jq && rm -rf /var/cache/apk/*
RUN ln -s /opt/tegola /usr/bin/tegola

# Volumen
VOLUME /mnt/data
# Copy config and exec files
COPY ./config/config.toml /opt/tegola_config/config.toml
COPY ./tile2bounds.py .
Expand All @@ -52,4 +33,5 @@ COPY ./seed-by-diffs.sh .
COPY ./tile_cache_downloader.sh .
COPY ./cache_cleaner.sh .
COPY ./rm_tegola_ps.sh .
# CMD ./start.sh & ./tile_cache_downloader.sh & ./expire-watcher.sh
ENTRYPOINT ["/bin/bash", "-c"]
CMD ./start.sh & ./tile_cache_downloader.sh & ./expire-watcher.sh
149 changes: 126 additions & 23 deletions images/tiler-server/config/config.toml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions images/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ RUN npm install -g svgo

# Install openstreetmap-website
RUN rm -rf $workdir/html
ENV OPENHISTORICALMAP_WEBSITE_GITSHA=4ce9b914ba7277593fe86bc35f3f5851430fd39b
ENV OPENHISTORICALMAP_WEBSITE_GITSHA=2af1cb7b4257ac0ec1ba63a050d9161d8d9698e3
RUN git clone -b staging https://github.com/OpenHistoricalMap/ohm-website.git $workdir
WORKDIR $workdir
RUN git checkout $OPENHISTORICALMAP_WEBSITE_GITSHA

# change the echo here with a reason for changing the commithash
RUN echo 'reorder railway style, update help, latest translations'
RUN echo 'update map styles, oauth2 code, latest translations'
RUN git fetch

# Install Ruby packages
Expand Down
6 changes: 6 additions & 0 deletions images/web/config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ initial_changeset_comments_per_hour: 6
max_changeset_comments_per_hour: 60
moderator_changeset_comments_per_hour: 36000
embed_server_url: "https://embed.openhistoricalmap.org/"

# Private key for signing id_tokens
doorkeeper_signing_key: |
-----BEGIN PRIVATE KEY-----
PRIVATE_KEY
-----END PRIVATE KEY-----
6 changes: 6 additions & 0 deletions images/web/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/config/settings.yml
sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/app/views/site/export.html.erb
sed -i -e 's/overpass-api.de/'$OVERPASS_URL'/g' $workdir/app/assets/javascripts/index/export.js

# ADD DOORKEEPER_SIGNING_KEY
openssl genpkey -algorithm RSA -out private.pem
chmod 400 /var/www/private.pem
export DOORKEEPER_SIGNING_KEY=$(cat /var/www/private.pem | sed -e '1d;$d' | tr -d '\n')
sed -i "s#PRIVATE_KEY#${DOORKEEPER_SIGNING_KEY}#" $workdir/config/settings.yml

#### CHECK IF DB IS ALREADY UP AND START THE APP
flag=true
while "$flag" = true; do
Expand Down
2 changes: 1 addition & 1 deletion ohm/requirements.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dependencies:
- name: osm-seed
version: '0.1.0-n776.h230d7d8'
version: '0.1.0-n775.h6785acb'
repository: https://devseed.com/osm-seed-chart/
5 changes: 3 additions & 2 deletions values.production.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ osm-seed:
OVERPASS_URL: overpass-api.openhistoricalmap.org
NEW_RELIC_LICENSE_KEY: {{PRODUCTION_NEW_RELIC_LICENSE_KEY}}
NEW_RELIC_APP_NAME: {{PRODUCTION_NEW_RELIC_APP_NAME}}
ORGANIZATION_NAME: OpenHistoricalMap
resources:
enabled: true
requests:
Expand Down Expand Up @@ -706,8 +707,8 @@ osm-seed:
osmchaApi:
enabled: true
image:
name: "ghcr.io/willemarcel/osmcha-django"
tag: "2975f9242b7bf70a840120b3dae6778c9d12146b"
name: "ghcr.io/openhistoricalmap/osmcha-django"
tag: "a1bcea85dc1f7c27566c20bafe7fff7aaa1e38a4"
env:
DJANGO_SETTINGS_MODULE: "config.settings.production"
OSMCHA_FRONTEND_VERSION: "v0.86.0-production"
Expand Down
5 changes: 3 additions & 2 deletions values.staging.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ osm-seed:
OVERPASS_URL: overpass-api-staging.openhistoricalmap.org
NEW_RELIC_LICENSE_KEY: {{STAGING_NEW_RELIC_LICENSE_KEY}}
NEW_RELIC_APP_NAME: {{STAGING_NEW_RELIC_APP_NAME}}
ORGANIZATION_NAME: OpenHistoricalMap
resources:
enabled: true
requests:
Expand Down Expand Up @@ -741,8 +742,8 @@ osm-seed:
osmchaApi:
enabled: true
image:
name: "ghcr.io/willemarcel/osmcha-django"
tag: "2975f9242b7bf70a840120b3dae6778c9d12146b"
name: "ghcr.io/openhistoricalmap/osmcha-django"
tag: "a1bcea85dc1f7c27566c20bafe7fff7aaa1e38a4"
env:
DJANGO_SETTINGS_MODULE: "config.settings.production"
OSMCHA_FRONTEND_VERSION: "v0.86.0-production"
Expand Down
Loading