-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: encode env as build args for frontend build
- Loading branch information
1 parent
4858fc7
commit 2c7f0fd
Showing
4 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,34 @@ jobs: | |
dockerfile: Dockerfile | ||
secrets: inherit | ||
|
||
get_envs: | ||
uses: hotosm/gh-workflows/.github/workflows/[email protected] | ||
with: | ||
environment: ${{ github.ref_name }} | ||
secrets: inherit | ||
|
||
encode_envs: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- get_envs | ||
outputs: | ||
base64_env: ${{ steps.to_base64.outputs.base64_env }} | ||
steps: | ||
- name: Export env to base64 for frontend build | ||
id: to_base64 | ||
run: | | ||
echo "base64_env=`${{ needs.get_envs.outputs.all_vars }}' | base64`" >> "$GITHUB_OUTPUT" | ||
frontend-build: | ||
uses: hotosm/gh-workflows/.github/workflows/[email protected] | ||
needs: | ||
- encode_envs | ||
with: | ||
context: ./src/frontend | ||
build_target: live | ||
image_name: ghcr.io/${{ github.repository }}/frontend | ||
dockerfile: Dockerfile | ||
extra_build_args: B64_ARGS_TO_ENV=${{ needs.encode_envs.outputs.base64_env }} | ||
secrets: inherit | ||
|
||
postgres-vol-creation: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
# ARG for the base image | ||
ARG NODE_BASE=18.16.0-bullseye-slim | ||
ARG MINIO_TAG=RELEASE.2024-08-03T04-33-23Z | ||
ARG B64_ARGS_TO_ENV | ||
|
||
# Base image with frontend code | ||
FROM node:${NODE_BASE} AS base | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
COPY ./package.json . | ||
RUN ["/bin/sh", "-c", "env | tee .env"] | ||
RUN yarn | ||
|
||
# Run development environment | ||
FROM base AS development | ||
COPY . /app | ||
ENTRYPOINT ["/bin/sh", "-c", "yarn start --host 0.0.0.0;"] | ||
ENTRYPOINT ["/bin/sh", "-c", "yarn; yarn start --host 0.0.0.0;"] | ||
|
||
# Generate frontend build files | ||
FROM base AS build | ||
ARG B64_ARGS_TO_ENV | ||
COPY ./package.json . | ||
RUN yarn | ||
COPY . /app | ||
RUN ( echo ${B64_ARGS_TO_ENV} | base64 -d ) > .env | ||
RUN yarn build | ||
|
||
# Copy static files to minio and generated index.html to volume | ||
FROM docker.io/minio/minio:${MINIO_TAG} AS live | ||
COPY --from=build /app/dist /tmp/dist | ||
RUN ( echo ${B64_ARGS_TO_ENV} | base64 -d ) > /.env | ||
VOLUME /tmp/frontend_html | ||
COPY ./docker-entrypoint.sh /docker-entrypoint.sh | ||
ENTRYPOINT [ "/docker-entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters