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

Rolling back to dev and SPIRE health check time automation #206

Merged
merged 2 commits into from
May 11, 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
37 changes: 4 additions & 33 deletions Dockerfile.frontend-container
Original file line number Diff line number Diff line change
@@ -1,48 +1,19 @@
# Build stage
FROM node:16-alpine3.14 AS build
FROM node:16-alpine

WORKDIR /usr/src/app

COPY tornjak-frontend .

RUN npm install --omit=dev && \
npm run build
RUN npm install --omit=dev

# Runtime stage
FROM node:16-alpine3.14 AS runtime

WORKDIR /usr/src/app

COPY --from=build /usr/src/app/build .
COPY --from=build /usr/src/app/.env.prod .

# install serve package
RUN npm install -g serve
RUN npm prune --production

# set env variables
ARG REACT_APP_API_SERVER_URI
ARG REACT_APP_AUTH_SERVER_URI
ARG REACT_APP_SPIRE_HEALTH_CHECK_ENABLE
ARG REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC

ENV REACT_APP_API_SERVER_URI $REACT_APP_API_SERVER_URI
ENV REACT_APP_AUTH_SERVER_URI $REACT_APP_AUTH_SERVER_URI
ENV REACT_APP_SPIRE_HEALTH_CHECK_ENABLE $REACT_APP_SPIRE_HEALTH_CHECK_ENABLE
ENV REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC $REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC
# ENV NODE_OPTIONS $NODE_OPTIONS
# ARG NODE_OPTIONS=--openssl-legacy-provider

ENV PORT_FE=3000
EXPOSE $PORT_FE

# CMD ["serve", "-s", "."]
# CMD ["sh", "-c", "PORT=$PORT_FE serve -s build"]
# CMD ["npm", "start"]

CMD serve -s . -p $PORT_FE

# CMD 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 \
# REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC=$REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC \
# serve -s . -p $PORT_FE
CMD ["npm", "start"]
7 changes: 3 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ The frontend is meant to connect to either the Tornjak backend or the Tornjak ma
| `REACT_APP_AUTH_SERVER_URI` | URI for the Keycloak instance to obtain access tokens | | `http://localhost:8080` | false |
| `PORT_FE` | Port for the frontend to run | `3000` | `3000` | true |
| `PORT_BE` | Port for the backend to run | `10000` | `10000` | true |
| `REACT_APP_SPIRE_HEALTH_CHECK` | Enable SPIRE health check component | `true` | `true` | false |
| `REACT_APP_SPIRE_HEALTH_CHECK_TIME` | Set how often SPIRE health should be checked, if component enabled | `120` | `240` | false |
| `REACT_APP_SPIRE_HEALTH_CHECK_ENABLE` | Enable SPIRE health check component | `false` | `true` | false |

```
docker run -p 3000:8080 -e REACT_APP_API_SERVER_URI='http://localhost:50000' -e REACT_APP_TORNJAK_MANAGER=true -e PORT_FE-8080 -e REACT_APP_SPIRE_HEALTH_CHECK=true -e REACT_APP_SPIRE_HEALTH_CHECK_TIME=120 ghcr.io/spiffe/tornjak-frontend:latest
docker run -p 3000:8080 -e REACT_APP_API_SERVER_URI='http://localhost:50000' -e REACT_APP_TORNJAK_MANAGER=true -e PORT_FE-8080 -e REACT_APP_SPIRE_HEALTH_CHECK=true ghcr.io/spiffe/tornjak-frontend:latest
```

The above command is an example of how to run the frontend. This creates a UI available at http://localhost:3000 forwarded from container port `8080`. It is listening to a Tornjak manager component available at http://localhost:50000, and knows to run in manager mode with the `REACT_APP_TORNJAK_MANAGER` flag. The last two environment variables namely, [`REACT_APP_SPIRE_HEALTH_CHECK` & `REACT_APP_SPIRE_HEALTH_CHECK_TIME`] are used to enable the SPIRE health check component and set how often it should be checked respectively.
The above command is an example of how to run the frontend. This creates a UI available at http://localhost:3000 forwarded from container port `8080`. It is listening to a Tornjak manager component available at http://localhost:50000, and knows to run in manager mode with the `REACT_APP_TORNJAK_MANAGER` flag. The last environment variables namely, `REACT_APP_SPIRE_HEALTH_CHECK_ENABLE` is used to enable the SPIRE health check component.

## Tornjak

Expand Down
3 changes: 1 addition & 2 deletions docker-compose-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ services:
- "PORT_FE=8080"
- "REACT_APP_API_SERVER_URI=http://localhost:10000"
# - "REACT_APP_AUTH_SERVER_URI=http://localhost:8080"
- REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
# - REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC=120
- REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
4 changes: 1 addition & 3 deletions tornjak-frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ REACT_APP_API_SERVER_URI=http://localhost:10000/


##### To check SPIRE health #####
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
# REACT_APP_SPIRE_HEALTH_CHECK_TIME is in seconds
REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC=120
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
4 changes: 1 addition & 3 deletions tornjak-frontend/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ REACT_APP_API_SERVER_URI=http://localhost:10000/


##### To check SPIRE health #####
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
# REACT_APP_SPIRE_HEALTH_CHECK_TIME is in seconds
REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC=120
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
6 changes: 2 additions & 4 deletions tornjak-frontend/.env.staging
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
REACT_APP_API_SERVER_URI=http://localhost:10000/
REACT_APP_AUTH_SERVER_URI=http://localhost:8080/
#REACT_APP_AUTH_SERVER_URI=http://localhost:8080/
##### To check SPIRE health #####
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
# REACT_APP_SPIRE_HEALTH_CHECK_TIME is in seconds
REACT_APP_SPIRE_HEALTH_CHECK_FREQ_SEC=120
REACT_APP_SPIRE_HEALTH_CHECK_ENABLE=false
Loading