Skip to content

Commit 6c1a80d

Browse files
committed
Osmcha web continaer
1 parent fa6fabc commit 6c1a80d

File tree

3 files changed

+93
-65
lines changed

3 files changed

+93
-65
lines changed

compose/osmcha.yml

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,39 @@
1-
version: "3.8"
21
services:
3-
web:
4-
platform: linux/amd64
5-
image: developmentseed/osmseed-osmcha-web:v16
2+
django:
3+
image: "ghcr.io/openhistoricalmap/osmcha-django:upstream_main"
4+
depends_on:
5+
- redis
6+
volumes:
7+
# Copy static files into a shared volume so the frontend can serve them
8+
- staticfiles:/app/staticfiles
9+
env_file: ./../envs/.env.osmcha
10+
ports:
11+
- "5001:5000"
12+
entrypoint: ["/bin/sh", "-c"]
13+
command:
14+
- |
15+
python manage.py migrate --verbosity 3 && \
16+
python manage.py collectstatic --noinput && \
17+
gunicorn config.wsgi -t 120 -b 0.0.0.0:5000 --access-logfile - --log-level debug
18+
frontend:
619
build:
720
context: ../images/osmcha-web
821
dockerfile: Dockerfile
9-
env_file:
10-
- ../envs/.env.osmcha
22+
depends_on:
23+
- django
1124
volumes:
12-
- ../data/osmcha/staticfiles:/staticfiles
13-
db:
14-
platform: linux/amd64
15-
image: osmseed-osmcha-db:v1
16-
build:
17-
context: ../images/osmcha-db
18-
dockerfile: Dockerfile
25+
# frontend serves django app's static files via shared volume
26+
- staticfiles:/srv/www/static/django
27+
env_file: ./../envs/.env.osmcha
28+
1929
ports:
20-
- "5432:5432"
21-
volumes:
22-
- ../data/osmcha-db-data:/var/lib/postgresql/data
23-
env_file:
24-
- ../envs/.env.osmcha
25-
init:
26-
platform: linux/amd64
27-
image: ghcr.io/willemarcel/osmcha-django:b1f4e6afc90e08707cadc4d74580632ca3b93dd2
28-
command: >
29-
/bin/bash -c "
30-
set -x
31-
python manage.py collectstatic
32-
python manage.py migrate
33-
mkdir -p /staticfiles/static
34-
cp -r /app/staticfiles/* /staticfiles/static/
35-
"
36-
env_file:
37-
- ../envs/.env.osmcha
38-
volumes:
39-
- ../data/osmcha/staticfiles:/staticfiles
40-
api:
41-
platform: linux/amd64
42-
image: ghcr.io/willemarcel/osmcha-django:b1f4e6afc90e08707cadc4d74580632ca3b93dd2
43-
build:
44-
context: ../images/osmcha-api
45-
dockerfile: Dockerfile
46-
command: >
47-
/bin/bash -c "
48-
set -x
49-
python manage.py collectstatic
50-
python manage.py migrate
51-
mkdir -p /staticfiles/static
52-
cp -r /app/staticfiles/* /staticfiles/static/
53-
gunicorn --workers 4 --bind 0.0.0.0:5000 --log-file - --access-logfile - config.wsgi
54-
"
30+
- "8000:80"
31+
32+
redis:
33+
image: redis:latest
34+
container_name: redis
35+
restart: always
5536
ports:
56-
- "5000:5000"
57-
env_file:
58-
- ../envs/.env.osmcha
59-
volumes:
60-
- ../data/osmcha/staticfiles:/staticfiles
37+
- "6379:6379"
38+
volumes:
39+
staticfiles:

images/osmcha-web/Dockerfile

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1-
FROM node:16-slim as builder
1+
FROM node:22-alpine as builder
2+
23
ENV DEBIAN_FRONTEND noninteractive
3-
ENV BUILD_ENV=prod
4-
ENV REACT_APP_PRODUCTION_API_URL=/api/v1
5-
RUN apt-get update && apt-get install -y git \
6-
&& rm -rf /var/lib/apt/lists/*
7-
RUN mkdir /app
8-
WORKDIR /app
4+
95
ARG GITSHA=3cd987bd2ed02bbb60b121ecad0bb556a115aca1
10-
RUN git clone https://github.com/osmus/osmcha-frontend.git /app
11-
RUN git checkout $GITSHA
6+
ARG BUILD_ENV=prod
7+
8+
WORKDIR /app
9+
10+
## Clone osmcha repo
11+
RUN apk add --no-cache git \
12+
&& git clone https://github.com/OSMCha/osmcha-frontend.git /app \
13+
&& cd /app \
14+
&& git checkout $GITSHA
15+
16+
RUN yarn set version stable
1217
RUN yarn install
13-
RUN yarn build:prod
14-
COPY start.sh .
15-
CMD [ "/app/start.sh" ]
18+
19+
ENV REACT_APP_PRODUCTION_API_URL /api/v1
20+
ENV NODE_OPTIONS --openssl-legacy-provider
21+
22+
RUN yarn run build:${BUILD_ENV}
23+
24+
FROM nginx:alpine
25+
26+
COPY --from=builder /app/build /srv/www
27+
28+
COPY nginx.conf /etc/nginx/templates/default.conf.template

images/osmcha-web/nginx.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
server {
2+
listen 80;
3+
charset utf-8;
4+
5+
include /etc/nginx/mime.types;
6+
default_type application/octet-stream;
7+
8+
gzip on;
9+
sendfile on;
10+
tcp_nopush on;
11+
tcp_nodelay on;
12+
keepalive_timeout 65;
13+
14+
location ~ ^/(api|admin) {
15+
# /api and /admin routes are handled by the backend
16+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17+
proxy_set_header Host $http_host;
18+
proxy_redirect off;
19+
proxy_pass $BACKEND_URL;
20+
}
21+
22+
location /static {
23+
# /static files are served without any magic (exact path or 404)
24+
root /srv/www;
25+
try_files $uri =404;
26+
}
27+
28+
location / {
29+
# other routes are served by trying the exact path, and falling back to
30+
# serving the app entrypoint (index.html). this is needed because the
31+
# frontend JS code uses the path component of the URL in its client-side
32+
# routing.
33+
root /srv/www;
34+
try_files $uri $uri/ /index.html;
35+
}
36+
}

0 commit comments

Comments
 (0)