Skip to content

Commit

Permalink
Update osmcha deployment
Browse files Browse the repository at this point in the history
Update osmcha deployment

Update services
  • Loading branch information
Rub21 committed Dec 21, 2023
1 parent 8871c57 commit 772fc91
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 47 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
12 changes: 9 additions & 3 deletions images/osmcha-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ 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
RUN yarn build:${BUILD_ENV}

FROM nginx:alpine
COPY --from=builder /app/build /assets
COPY --from=builder /app/build /assets
8 changes: 0 additions & 8 deletions images/osmcha-web/start.sh

This file was deleted.

5 changes: 0 additions & 5 deletions images/osmcha-web/supervisord.conf

This file was deleted.

8 changes: 6 additions & 2 deletions osm-seed/templates/osmcha-app/configMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ data:
DJANGO_DEBUG: "False"
DJANGO_ENV: "production"
# OSM_SERVER_URL: {{ .Values.osmchaApi.env.OSM_SERVER_URL | quote }}
REDIS_URL: {{ .Release.Name }}-osmcha-redis
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 All @@ -42,14 +43,17 @@ data:
}
http {
access_log /dev/stdout;
error_log /dev/stderr;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
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 }}
31 changes: 21 additions & 10 deletions osm-seed/templates/osmcha-app/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,42 @@ 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
- name: api
# securityContext:
# runAsUser: 0
image: "{{ .Values.osmchaApi.image.name }}:{{ .Values.osmchaApi.image.tag }}"
command:
- /bin/sh
- -c
- |
set -x
gunicorn --workers 4 --bind 0.0.0.0:5000 --log-file log-file.log --access-logfile access-logfile.log config.wsgi
echo "start app...."
gunicorn --workers 4 --bind 0.0.0.0:5000 --log-file - --access-logfile - config.wsgi
ports:
- containerPort: 5000
livenessProbe:
Expand All @@ -74,8 +82,11 @@ spec:
memory: {{ .Values.osmchaApi.resources.limits.memory }}
cpu: {{ .Values.osmchaApi.resources.limits.cpu }}
{{- end }}
- name: osmcha-nginx

- name: nginx
image: "{{ .Values.osmchaWeb.image.name }}:{{ .Values.osmchaWeb.image.tag }}"
ports:
- containerPort: 80
volumeMounts:
- name: osmcha-frontend-nginx-config
mountPath: /etc/nginx
Expand Down
4 changes: 2 additions & 2 deletions osm-seed/templates/osmcha-app/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }}
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
{{- end }}
{{- if eq .Values.serviceType "ClusterIP" }}
kubernetes.io/ingress.class: nginx
Expand All @@ -32,7 +32,7 @@ spec:
name: http
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
- port: 443
targetPort: http
targetPort: 80
protocol: TCP
name: https
{{- end }}
Expand Down

0 comments on commit 772fc91

Please sign in to comment.