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

Update compose and CI to deploy mapper frontend on push #1855

Merged
merged 5 commits into from
Nov 5, 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: 2 additions & 2 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
uses: hotosm/gh-workflows/.github/workflows/image_build.yml@2.0.6
needs: [frontend-unit-test, frontend-e2e-test]
with:
context: src/frontend
dockerfile: prod.dockerfile
context: src
dockerfile: Dockerfile.ui.prod
build_target: prod
image_name: ghcr.io/${{ github.repository }}/frontend

Expand Down
12 changes: 8 additions & 4 deletions docker-compose.development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ name: fmtm-dev
volumes:
fmtm_frontend:
name: fmtm-frontend-${GIT_BRANCH}
fmtm_mapper_frontend:
name: fmtm-mapper-frontend-${GIT_BRANCH}
fmtm_db_data:
name: fmtm-db-data-${GIT_BRANCH}
fmtm_data:
Expand Down Expand Up @@ -60,7 +62,8 @@ services:
ui:
condition: service_completed_successfully
volumes:
- fmtm_frontend:/usr/share/nginx/html/fmtm/
- fmtm_frontend:/usr/share/nginx/html/fmtm-manager/
- fmtm_frontend:/usr/share/nginx/html/fmtm-mapper/
- central_frontend:/usr/share/nginx/html/central/
- certs:/etc/letsencrypt
- certbot_data:/var/www/certbot
Expand Down Expand Up @@ -114,14 +117,15 @@ services:
# accessible to the proxy, then shuts down
image: "ghcr.io/hotosm/fmtm/frontend:${GIT_BRANCH:-development}"
build:
context: src/frontend
dockerfile: prod.dockerfile
context: src
dockerfile: Dockerfile.ui.prod
args:
APP_VERSION: ${GIT_BRANCH}
VITE_API_URL: https://${FMTM_API_DOMAIN:-api.${FMTM_DOMAIN}}
NODE_ENV: development
volumes:
- fmtm_frontend:/frontend
- fmtm_frontend:/frontend/fmtm-manager
- fmtm_mapper_frontend:/frontend/fmtm-mapper
network_mode: none
restart: "on-failure:2"

Expand Down
12 changes: 8 additions & 4 deletions docker-compose.main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ name: fmtm-main
volumes:
fmtm_frontend:
name: fmtm-frontend-main
fmtm_mapper_frontend:
name: fmtm-mapper-frontend-main
fmtm_db_data:
name: fmtm-db-data-main
fmtm_data:
Expand Down Expand Up @@ -52,7 +54,8 @@ services:
ui:
condition: service_completed_successfully
volumes:
- fmtm_frontend:/usr/share/nginx/html/fmtm/
- fmtm_frontend:/usr/share/nginx/html/fmtm-manager/
- fmtm_frontend:/usr/share/nginx/html/fmtm-mapper/
- certs:/etc/letsencrypt
- certbot_data:/var/www/certbot
environment:
Expand Down Expand Up @@ -104,14 +107,15 @@ services:
# accessible to the proxy, then shuts down
image: "ghcr.io/hotosm/fmtm/frontend:main"
build:
context: src/frontend
dockerfile: prod.dockerfile
context: src
dockerfile: Dockerfile.ui.prod
args:
APP_VERSION: main
VITE_API_URL: https://${FMTM_API_DOMAIN:-api.${FMTM_DOMAIN}}
NODE_ENV: production
volumes:
- fmtm_frontend:/frontend
- fmtm_frontend:/frontend/fmtm-manager
- fmtm_mapper_frontend:/frontend/fmtm-mapper
network_mode: none
restart: "on-failure:2"

Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ services:
ui:
image: "ghcr.io/hotosm/fmtm/frontend:debug"
build:
context: src/frontend
dockerfile: debug.dockerfile
context: src
additional_contexts:
- code=src/frontend
dockerfile: Dockerfile.ui.debug
depends_on:
api:
condition: service_started
Expand All @@ -137,8 +139,10 @@ services:
ui-mapper:
image: "ghcr.io/hotosm/fmtm/frontend:mapper"
build:
context: src/mapper
dockerfile: debug.dockerfile
context: src
additional_contexts:
- code=src/frontend
dockerfile: Dockerfile.ui.debug
depends_on:
api:
condition: service_started
Expand Down
10 changes: 8 additions & 2 deletions nginx/templates/fmtm.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ server {
# For opentelemetry
add_header 'Access-Control-Allow-Headers' 'traceparent,tracestate';

location /mapnow {
# Serve FMTM mapper frontend under /usr/share/nginx/html
root /usr/share/nginx/html/fmtm-mapper;
try_files $uri $uri/ /index.html;
}

location / {
# Serve FMTM frontend under /usr/share/nginx/html
root /usr/share/nginx/html/fmtm;
# Serve FMTM management frontend under /usr/share/nginx/html
root /usr/share/nginx/html/fmtm-manager;
try_files $uri $uri/ /index.html;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN set -ex \
"openssl" \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY ./package.json ./pnpm-lock.yaml ./
COPY --from=code ./package.json ./pnpm-lock.yaml ./
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack use pnpm@9.3.0
Expand Down
33 changes: 20 additions & 13 deletions src/frontend/prod.dockerfile β†’ src/Dockerfile.ui.prod
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
FROM docker.io/node:20 as builder

FROM docker.io/node:20 as base
ARG NODE_ENV
ARG VITE_API_URL
ENV VITE_API_URL="${VITE_API_URL}"

WORKDIR /app
COPY ./package.json ./pnpm-lock.yaml ./
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
ENV VITE_API_URL=${VITE_API_URL} \
NODE_ENV=${NODE_ENV} \
PNPM_HOME="/pnpm" \
PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack use pnpm@9.3.0
RUN pnpm install
WORKDIR /app

ARG NODE_ENV
ENV NODE_ENV ${NODE_ENV}
COPY . .

FROM base as manager-frontend
COPY frontend/package.json frontend/pnpm-lock.yaml ./
RUN pnpm install
COPY frontend/ .
RUN pnpm run build --mode ${NODE_ENV}


FROM base as mapper-frontend
COPY mapper/package.json mapper/pnpm-lock.yaml ./
RUN pnpm install
COPY mapper/ .
RUN pnpm run build --mode ${NODE_ENV}


FROM docker.io/rclone/rclone:1 as prod
ARG APP_VERSION
Expand All @@ -31,4 +37,5 @@ COPY container-entrypoint.sh /
RUN chmod +x /container-entrypoint.sh
ENTRYPOINT ["/container-entrypoint.sh"]
WORKDIR /app
COPY --from=builder /app/dist .
COPY --from=manager-frontend /app/dist ./manager-frontend
COPY --from=mapper-frontend /app/build ./mapper-frontend
2 changes: 1 addition & 1 deletion src/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ FROM base AS extract-deps
WORKDIR /opt/python
COPY pyproject.toml pdm.lock /opt/python/
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir pdm==2.6.1
&& pip install --no-cache-dir pdm==2.19.3
RUN pdm export --prod > requirements.txt \
# Export with default deps, as we install one or the other
&& pdm export -G monitoring \
Expand Down
Loading
Loading