diff --git a/images/osmcha-web/Dockerfile b/images/osmcha-web/Dockerfile index 186e42dc..4a56b1a0 100644 --- a/images/osmcha-web/Dockerfile +++ b/images/osmcha-web/Dockerfile @@ -1,25 +1,12 @@ FROM node:16-slim as builder - ENV DEBIAN_FRONTEND noninteractive - -ARG BUILD_ENV=prod - -## 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 - +ENV BUILD_ENV=prod +ENV REACT_APP_PRODUCTION_API_URL=/api/v1 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 git clone https://github.com/Rub21/osmcha-frontend.git /app +RUN git checkout env/realchangesets 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 start.sh . +CMD [ "/app/start.sh" ] diff --git a/images/osmcha-web/start.sh b/images/osmcha-web/start.sh new file mode 100755 index 00000000..661b6d28 --- /dev/null +++ b/images/osmcha-web/start.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -x +export BUILD_ENV=prod +export REACT_APP_PRODUCTION_API_URL=/api/v1 +sed -i "s|https://osmcha.org|$OSMCHA_URL|g" package.json +yarn build:${BUILD_ENV} +find /app/build -type f -exec sed -i "s/www.openstreetmap.org/$OSMCHA_API_URL/g" {} + +cp -r /app/build/* /assets/ diff --git a/osm-seed/templates/osmcha-app/configMap.yaml b/osm-seed/templates/osmcha-app/configMap.yaml index acb311f8..c758acdc 100644 --- a/osm-seed/templates/osmcha-app/configMap.yaml +++ b/osm-seed/templates/osmcha-app/configMap.yaml @@ -20,15 +20,21 @@ data: OAUTH_OSM_SECRET: {{ .Values.osmchaApi.env.OAUTH_OSM_SECRET | quote }} OAUTH_REDIRECT_URI: {{ .Values.osmchaApi.env.OAUTH_REDIRECT_URI | quote }} DJANGO_SECURE_SSL_REDIRECT: "False" - OSMCHA_URL: {{ .Values.osmchaApi.env.OSMCHA_URL | quote }} DJANGO_DEBUG: "False" DJANGO_ENV: "production" OSM_SERVER_URL: {{ .Values.osmchaApi.env.OSM_SERVER_URL | quote }} DJANGO_DEBUG: "False" 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 }} + # frontend + OSMCHA_URL: {{ .Values.osmchaApi.env.OSMCHA_URL | quote }} + OSMCHA_API_URL: {{ .Values.osmchaApi.env.OSMCHA_API_URL | quote }} + REACT_APP_OSM_URL: {{ .Values.osmchaApi.env.REACT_APP_OSM_URL | quote }} + REACT_APP_OSM_API: {{ .Values.osmchaApi.env.REACT_APP_OSM_API | quote }} + REACT_APP_OVERPASS_BASE: {{ .Values.osmchaApi.env.REACT_APP_OVERPASS_BASE | quote }} + REACT_APP_ENABLE_REAL_CHANGESETS: .Values.osmchaApi.env.REACT_APP_ENABLE_REAL_CHANGESETS }}" + REACT_APP_MAPBOX_ACCESS_TOKEN: {{ .Values.osmchaApi.env.REACT_APP_MAPBOX_ACCESS_TOKEN | quote }} --- apiVersion: v1 kind: ConfigMap diff --git a/osm-seed/templates/osmcha-app/deployment.yaml b/osm-seed/templates/osmcha-app/deployment.yaml index 8e7d46f1..95f29cf9 100644 --- a/osm-seed/templates/osmcha-app/deployment.yaml +++ b/osm-seed/templates/osmcha-app/deployment.yaml @@ -23,6 +23,14 @@ spec: run: {{ .Release.Name }}-osmcha-app spec: initContainers: + - name: web-builder + image: "{{ .Values.osmchaWeb.image.name }}:{{ .Values.osmchaWeb.image.tag }}" + envFrom: + - configMapRef: + name: {{ .Release.Name }}-osmcha-common-env + volumeMounts: + - name: nginx-assets + mountPath: /assets - name: init image: "{{ .Values.osmchaApi.image.name }}:{{ .Values.osmchaApi.image.tag }}" command: @@ -84,7 +92,7 @@ spec: {{- end }} - name: nginx - image: "{{ .Values.osmchaWeb.image.name }}:{{ .Values.osmchaWeb.image.tag }}" + image: "nginx:latest" ports: - containerPort: 80 volumeMounts: @@ -93,9 +101,13 @@ spec: readOnly: true - name: staticfiles mountPath: /staticfiles + - name: nginx-assets + mountPath: /assets volumes: - name: staticfiles emptyDir: {} + - name: nginx-assets + emptyDir: {} - name: osmcha-frontend-nginx-config configMap: name: {{ .Release.Name }}-osmcha-nginx-config