Skip to content

Commit

Permalink
Parameterizing ports in docker files (#159)
Browse files Browse the repository at this point in the history
* parameterize ports in docker file

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

* implement health check (#161)

* implemented health check

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* fixing lint check

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* reverting cmd file

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* nit

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* added debug server call

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* adding documentation

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* attempting to clean lint

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* attempt to remove lint

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* removing deadcode

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* removing more deadcode

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* removing more deadcode

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* removing more deadcode

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

---------

Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>

* adding documentation

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>

---------

Signed-off-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>
Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>
Co-authored-by: Mohammed Abdi <moabdi@Mohammeds-MBP-2.attlocal.net>
Co-authored-by: Maia Iyer <maia.raj.iyer@gmail.com>
  • Loading branch information
3 people committed Apr 20, 2023
1 parent e3e9a20 commit 820924f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Dockerfile.frontend-container
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ ENV REACT_APP_API_SERVER_URI $REACT_APP_API_SERVER_URI
ENV REACT_APP_AUTH_SERVER_URI $REACT_APP_AUTH_SERVER_URI
ENV NODE_OPTIONS $NODE_OPTIONS
ARG NODE_OPTIONS=--openssl-legacy-provider
EXPOSE 3000

ENV PORT_FE=3000
EXPOSE $PORT_FE

CMD ["npm", "start"]
7 changes: 5 additions & 2 deletions Dockerfile.tornjak-container
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ ENV REACT_APP_AUTH_SERVER_URI $REACT_APP_AUTH_SERVER_URI
ARG NODE_OPTIONS=--openssl-legacy-provider
ENV NODE_OPTIONS $NODE_OPTIONS

EXPOSE 3000
EXPOSE 10000
# front-end port
ENV PORT_FE=3000
# back-end port
ENV PORT_BE=10000
EXPOSE $PORT_FE $PORT_BE

# start app
ENTRYPOINT ["/opt/spire/run_tornjak.sh"]
10 changes: 6 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ The frontend is meant to connect to either the Tornjak backend or the Tornjak ma
| `NODE_OPTIONS` | Node options for npm start | `--openssl-legacy-provider` | `--openssl-legacy-provider` | false |
| `REACT_APP_TORNJAK_MANAGER` | Boolean for whether the connected server is a manager | `false` | `true` | false |
| `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 |

```
docker run -p 3000:3000 -e REACT_APP_API_SERVER_URI='http://localhost:50000' -e REACT_APP_TORNJAK_MANAGER=true ghcr.io/spiffe/tornjak-fe: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 ghcr.io/spiffe/tornjak-fe: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 3000. 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 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.

## Tornjak

Expand All @@ -60,10 +62,10 @@ This container may be used as an alternative to having a frontend and backend co
An example command:

```
docker run -p 10000:10000 -p 3000:3000 -e REACT_APP_API_SERVER_URI='http://localhost:10000' ghcr.io/spiffe/tornjak:latest -c <SPIRE CONFIG PATH> -t <TORNJAK CONFIG PATH>
docker run -p 10000:10000 -p 3000:8080 -e REACT_APP_API_SERVER_URI='http://localhost:10000' -e PORT_FE-8080 -e PORT_BE-10000 ghcr.io/spiffe/tornjak:latest -c <SPIRE CONFIG PATH> -t <TORNJAK CONFIG PATH>
```

The above command creates a UI available at `http://localhost:3000` forwarded from container port 3000. It is listening to the Tornjak backend at `http://localhost:10000`, as given by the `REACT_APP_API_SERVER_URI` value. At the same time, the container is exposing port 10000 for the backend, which reads the SPIRE config and Tornjak config at `<SPIRE CONFIG PATH>` and `<TORNJAK CONFIG PATH>` respectively.
The above command creates a UI available at `http://localhost:3000` forwarded from container port `8080`. It is listening to the Tornjak backend at `http://localhost:10000`, as given by the `REACT_APP_API_SERVER_URI` value. At the same time, the container is exposing port `10000` for the backend, which reads the SPIRE config and Tornjak config at `<SPIRE CONFIG PATH>` and `<TORNJAK CONFIG PATH>` respectively.

NOTE: The value of `REACT_APP_API_SERVER_URI` must be a URI that is separately available to any browser that accesses the frontend. Therefore, in production environments, it is necessary that backend service endpoint be public.

Expand Down
14 changes: 7 additions & 7 deletions tornjak-frontend/package-lock.json

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

2 changes: 1 addition & 1 deletion tornjak-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@babel/preset-env": "^7.15.6"
},
"scripts": {
"start": "react-scripts start --openssl-legacy-provider",
"start": "PORT=$PORT_FE react-scripts start --openssl-legacy-provider",
"build": "react-scripts build",
"build:staging": "env-cmd -f .env.staging npm run build",
"test": "react-scripts test",
Expand Down

0 comments on commit 820924f

Please sign in to comment.