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

Dynamically change frontend env variables and reduce image size #220

Merged
merged 3 commits into from
May 18, 2023
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
29 changes: 17 additions & 12 deletions Dockerfile.frontend-container
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
FROM node:16-alpine

## Build stage
FROM node:16-alpine3.14 AS build
WORKDIR /usr/src/app
CMD ["npm", "start"]
COPY tornjak-frontend .
RUN npm install --omit=dev && \
npm run build

# set env variables
ENV REACT_APP_API_SERVER_URI $REACT_APP_API_SERVER_URI \
REACT_APP_AUTH_SERVER_URI $REACT_APP_AUTH_SERVER_URI \
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE $REACT_APP_SPIRE_HEALTH_CHECK_ENABLE \
PORT_FE=3000
## Runtime stage
FROM node:16-alpine3.14 AS runtime
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/build ./build
COPY --from=build /usr/src/app/.env.prod .

# Install serve package and react-inject-env
RUN npm install --location=global serve && \
npm install react-inject-env

# Set dynamic port, defualt 3000
ENV PORT_FE=3000
EXPOSE $PORT_FE

COPY tornjak-frontend .
ENTRYPOINT npx react-inject-env set && npx serve build -p $PORT_FE

# add a version link to the image description
ARG version
LABEL org.opencontainers.image.description "https://github.com/spiffe/tornjak/releases/tag/$version"

RUN npm install --omit=dev \
npm prune --production
1 change: 1 addition & 0 deletions tornjak-frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GENERATE_SOURCEMAP=false
NODE_PATH=src/
SKIP_PREFLIGHT_CHECK=true
REACT_APP_DEBUG_TORNJAK=true
REACT_APP_TORNJAK_MANAGER=false

##### Backend Server uri
REACT_APP_API_SERVER_URI=http://localhost:10000/
Expand Down
2 changes: 1 addition & 1 deletion tornjak-frontend/.env.prod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REACT_APP_DEBUG_TORNJAK=true

REACT_APP_TORNJAK_MANAGER=false
##### Backend Server uri
REACT_APP_API_SERVER_URI=http://localhost:10000/

Expand Down
1 change: 1 addition & 0 deletions tornjak-frontend/.env.staging
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
REACT_APP_TORNJAK_MANAGER=false
REACT_APP_API_SERVER_URI=http://localhost:10000/
#REACT_APP_AUTH_SERVER_URI=http://localhost:8080/
##### To check SPIRE health #####
Expand Down
243 changes: 243 additions & 0 deletions tornjak-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading