Skip to content

Commit

Permalink
Update osmcha deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Dec 21, 2023
1 parent 9ec396b commit 95644d2
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ tiler-server/imposm/
overpass-api-db/
data/*/
!data/README.md
images/changeset-replication-job/config.yaml
images/changeset-replication-job/config.yaml
values_copy.yaml
56 changes: 40 additions & 16 deletions compose/osmcha.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
version: '3.8'
services:
version: "3.8"
services:
web:
platform: linux/amd64
image: developmentseed/osmseed-osmcha-web:v7
image: developmentseed/osmseed-osmcha-web:v16
build:
context: ../images/osmcha-web
dockerfile: Dockerfile
env_file:
- ../envs/.env.osmcha
- ../envs/.env.osmcha
volumes:
- ../data/osmcha/staticfiles:/staticfiles
- ../data/osmcha/staticfiles:/staticfiles
db:
platform: linux/amd64
image: osmseed-osmcha-db:v1
build:
context: ../images/osmcha-db
dockerfile: Dockerfile
ports:
- '5432:5432'
- "5432:5432"
volumes:
- ../data/osmcha-db-data:/var/lib/postgresql/data
- ../data/osmcha-db-data:/var/lib/postgresql/data
env_file:
- ../envs/.env.osmcha
api:
- ../envs/.env.osmcha
init:
platform: linux/amd64
image: ghcr.io/willemarcel/osmcha-django:b1f4e6afc90e08707cadc4d74580632ca3b93dd2
# build:
# context: ../images/osmcha-api
# dockerfile: Dockerfile
ports:
- '5000:5000'
command: >
/bin/bash -c "
set -x
python manage.py collectstatic
python manage.py migrate
mkdir -p /staticfiles/static
cp -r /app/staticfiles/* /staticfiles/static/
"
env_file:
- ../envs/.env.osmcha
- ../envs/.env.osmcha
volumes:
- ../data/osmcha/staticfiles:/staticfiles
- ../data/osmcha/staticfiles:/staticfiles
# api:
# platform: linux/amd64
# image: developmentseed/osmseed-osmcha-api:v8
# build:
# context: ../images/osmcha-api
# dockerfile: Dockerfile
# command: >
# /bin/bash -c "
# set -x
# python manage.py collectstatic
# python manage.py migrate
# mkdir -p /staticfiles/static
# cp -r /app/staticfiles/* /staticfiles/static/
# gunicorn --workers 4 --bind 0.0.0.0:3000 --log-file - --access-logfile - config.wsgi
# "
# ports:
# - "3000:3000"
# env_file:
# - ../envs/.env.osmcha
# volumes:
# - ../data/osmcha/staticfiles:/staticfiles
10 changes: 8 additions & 2 deletions images/osmcha-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ FROM node:16-slim as builder
ENV DEBIAN_FRONTEND noninteractive

ARG BUILD_ENV=prod
ARG OSMCHA_URL=https://osmcha-staging.openhistoricalmap.org

RUN apt-get update && apt-get install -y git
## Necesary env values to deploy
ENV OSMCHA_URL=https://osmcha-staging.openhistoricalmap.org
ENV OSMCHA_API_URL=www.openhistoricalmap.org
ENV REACT_APP_OSM_URL=https://www.openhistoricalmap.org
ENV REACT_APP_OSM_API=https://www.openhistoricalmap.org/api/0.6
ENV REACT_APP_OVERPASS_BASE=//overpass-api.openhistoricalmap.org/api/interpreter

RUN apt-get update && apt-get install -y git
RUN mkdir /app
WORKDIR /app
RUN git clone https://github.com/sunu/osmcha-frontend.git /app
RUN find /app -type f -exec sed -i 's/www.openstreetmap.org/www.openhistoricalmap.org/g' {} +
RUN yarn install
ENV REACT_APP_PRODUCTION_API_URL /api/v1
RUN sed -i "s|https://osmcha.org|$OSMCHA_URL|g" package.json
Expand Down
1 change: 1 addition & 0 deletions osm-seed/templates/osmcha-app/configMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ data:
DJANGO_ENV: "production"
# OSM_SERVER_URL: {{ .Values.osmchaApi.env.OSM_SERVER_URL | quote }}
REDIS_URL: "redis://{{ .Release.Name }}-osmcha-redis:6379"
OSM_PLANET_BASE_URL: {{ .Values.osmchaApi.env.OSM_PLANET_BASE_URL | quote }}
---
apiVersion: v1
kind: ConfigMap
Expand Down
32 changes: 32 additions & 0 deletions osm-seed/templates/osmcha-app/cronJob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.osmchaApi.enabled -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .Release.Name }}-osmcha-fetch-changesets-cronjob
labels:
app: {{ template "osm-seed.name" . }}
component: osmcha-app-deployment
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
schedule: "*/2 * * * *"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 2
failedJobsHistoryLimit: 2
jobTemplate:
spec:
template:
spec:
containers:
- name: {{ .Release.Name }}-osmcha-fetch-changesets
image: "{{ .Values.osmchaApi.image.name }}:{{ .Values.osmchaApi.image.tag }}"
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- python manage.py fetchchangesets
envFrom:
- configMapRef:
name: {{ .Release.Name }}-osmcha-common-env
restartPolicy: Never
{{- end }}
30 changes: 17 additions & 13 deletions osm-seed/templates/osmcha-app/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,41 @@ spec:
run: {{ .Release.Name }}-osmcha-app
spec:
initContainers:
- name: osmcha-init
- name: init
image: "{{ .Values.osmchaApi.image.name }}:{{ .Values.osmchaApi.image.tag }}"
command:
- /bin/sh
- -c
- |
set -x
python manage.py collectstatic
python manage.py migrate
mkdir -p /staticfiles/static
cp -r /app/staticfiles/* /staticfiles/static/
flag=true
while "$flag" = true; do
pg_isready -h $POSTGRES_HOST -p 5432 >/dev/null 2>&2 || continue
flag=false
python manage.py migrate
python manage.py collectstatic
mkdir -p /staticfiles/static
cp -r /app/staticfiles/* /staticfiles/static/
done
envFrom:
- configMapRef:
name: {{ .Release.Name }}-osmcha-common-env
volumeMounts:
- name: staticfiles
mountPath: /staticfiles
securityContext:
runAsUser: 0
# securityContext:
# runAsUser: 0
containers:
- name: osmcha-api
securityContext:
runAsUser: 0
- name: api
# securityContext:
# runAsUser: 0
image: "{{ .Values.osmchaApi.image.name }}:{{ .Values.osmchaApi.image.tag }}"
command:
- /bin/sh
- -c
- |
set -x
pip install git+https://github.com/OpenHistoricalMap/social-core.git &&
sed -i "s|https://api.openhistoricalmap.org/api/0.6/user/details|https://www.openhistoricalmap.org/api/0.6/user/details|g" /usr/local/lib/python3.10/site-packages/social_core/backends/openstreetmap.py
echo "start app...."
gunicorn --workers 4 --bind 0.0.0.0:5000 --log-file - --access-logfile - config.wsgi
ports:
- containerPort: 5000
Expand All @@ -79,7 +83,7 @@ spec:
cpu: {{ .Values.osmchaApi.resources.limits.cpu }}
{{- end }}

- name: osmcha-nginx
- name: nginx
image: "{{ .Values.osmchaWeb.image.name }}:{{ .Values.osmchaWeb.image.tag }}"
ports:
- containerPort: 80
Expand Down

0 comments on commit 95644d2

Please sign in to comment.