Skip to content

Commit

Permalink
front: fill git describe using vite instead of import-meta-env
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Amsallem <[email protected]>
  • Loading branch information
flomonster committed Jan 15, 2025
1 parent 32128d8 commit 884d2ae
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 165 deletions.
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ services:
additional_contexts:
test_data: tests/data
static_assets: assets
args:
OSRD_GIT_DESCRIBE: development
environment:
# Actual values in ./docker/osrdyne.yml (please maintain consistency)
# Provided here only for reuse in compose layers and doc
Expand All @@ -90,7 +92,7 @@ services:
test_data: tests/data
dockerfile: docker/Dockerfile.${OSRD_FRONT_MODE-devel}
args:
OSRD_GIT_DESCRIBE: ${OSRD_GIT_DESCRIBE}
OSRD_GIT_DESCRIBE: development
environment:
FRONT_PORT: 3000 # only useful with the prod config
OSRD_EDITOAST_URL: /api
Expand Down Expand Up @@ -120,6 +122,7 @@ services:
static_assets: assets
args:
CARGO_PROFILE: dev
OSRD_GIT_DESCRIBE: development
restart: unless-stopped
ports: [ "8090:80" ]
environment:
Expand Down
1 change: 0 additions & 1 deletion front/.env.example

This file was deleted.

4 changes: 4 additions & 0 deletions front/docker/Dockerfile.devel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ COPY --from=exec_as_builder /exec-as /

WORKDIR /app

# Fill build time values
ARG OSRD_GIT_DESCRIBE
ENV VITE_OSRD_GIT_DESCRIBE=${OSRD_GIT_DESCRIBE}

# Start the app
COPY docker/dev-entrypoint.sh /
ENTRYPOINT ["/dev-entrypoint.sh"]
Expand Down
16 changes: 7 additions & 9 deletions front/docker/Dockerfile.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ FROM node:20-bookworm AS build

WORKDIR /app


# Build dependencies
COPY package.json package-lock.json /app/
RUN npm install --frozen-lockfile

# Fill build time values
ARG OSRD_GIT_DESCRIBE
ENV VITE_OSRD_GIT_DESCRIBE=${OSRD_GIT_DESCRIBE}

# Generate the licenses file and build
COPY . /app
RUN npm run generate-licenses && npm run build
Expand All @@ -23,18 +28,11 @@ COPY --from=test_data . /tests/data

FROM nginx:alpine

RUN apk add npm && \
npm install -g @import-meta-env/cli && \
rm /etc/nginx/conf.d/default.conf

RUN rm /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/conf.d
COPY docker/nginx-entrypoint.sh /entrypoint.sh

COPY --from=build /app/build /srv
COPY --from=build /app/.env.example /

ARG OSRD_GIT_DESCRIBE
ENV OSRD_GIT_DESCRIBE=${OSRD_GIT_DESCRIBE}

ENTRYPOINT ["/entrypoint.sh"]
CMD ["sh", "-c", "npx import-meta-env -x /.env.example -p /srv/index.html && exec nginx -g 'daemon off;'"]
CMD ["nginx", "-g", "daemon off"]
Loading

0 comments on commit 884d2ae

Please sign in to comment.