Skip to content

Commit

Permalink
dev: resilient gateway build for dev front
Browse files Browse the repository at this point in the history
Signed-off-by: Élyse Viard <[email protected]>
  • Loading branch information
ElysaSrc authored and Khoyo committed Feb 8, 2025
1 parent e280875 commit 42f1939
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docker/docker-compose.front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ services:
image: ghcr.io/openrailassociation/osrd-edge/osrd-gateway:${TAG-dev}-${GATEWAY_FLAVOR-standalone}
volumes:
- "./docker/gateway.dev.front.toml:/srv/gateway.toml"
build:
args:
SKIP_FRONT: "1"

front:
image: ghcr.io/openrailassociation/osrd-edge/osrd-front:${TAG-dev}-dev
Expand Down
3 changes: 3 additions & 0 deletions docker/docker-compose.host-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ services:
image: ghcr.io/openrailassociation/osrd-edge/osrd-gateway:${TAG-dev}-${GATEWAY_FLAVOR-standalone}
volumes:
- "./docker/gateway.dev.host-front.toml:/srv/gateway.toml"
build:
args:
SKIP_FRONT: "1"

front:
image: ghcr.io/openrailassociation/osrd-edge/osrd-front:${TAG-dev}-dev
Expand Down
18 changes: 14 additions & 4 deletions gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,28 @@ CMD ["/usr/local/bin/osrd_gateway"]
FROM node:23-bookworm AS front_build
WORKDIR /app

# Build dependencies
COPY --from=front_src package.json package-lock.json /app/
RUN npm install --frozen-lockfile
# Add build argument for skipping failed front
ARG SKIP_FRONT=0

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

# Build dependencies
COPY --from=front_src package.json package-lock.json /app/

# If SKIP_FRONT is set to 1, skip the front build
RUN if [ "$SKIP_FRONT" = "1" ]; then exit 0; else npm ci; fi

# Generate the licenses file and build
COPY --from=front_src . /app
ENV NODE_OPTIONS="--max_old_space_size=4096"
RUN npm run generate-licenses && npm run build
RUN if [ "$SKIP_FRONT" = "1" ]; then \
mkdir -p build; \
echo '<html><body><h1>No front, as this image was built for running it in dev mode</h1></body></html>' > build/index.html; \
else \
(npm run generate-licenses && npm run build); \
fi

#######################
# Running env : front #
Expand Down

0 comments on commit 42f1939

Please sign in to comment.