Commit 46b77b25 authored by Adam Parák's avatar Adam Parák 💬
Browse files

Merge branch 'nginx-deployment' into 'master'

Nginx Docker Compose

See merge request inject/frontend!198
parents 81dfdff2 3b4ee4f0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ backend
.gitlab
**/dist
**/.swc
docker

.pnp.*
.yarn/*
+0 −7
Original line number Diff line number Diff line
@@ -22,11 +22,6 @@ COPY . .

RUN yarn workspace @inject/frontend prebuild

ARG VITE_HTTP_HOST=localhost:8000
ENV VITE_HTTP_HOST=$VITE_HTTP_HOST
ARG VITE_HTTP_WS=ws://localhost:8000/ttxbackend/v1/graphql
ENV VITE_HTTP_WS=$VITE_HTTP_WS

RUN yarn workspace @inject/frontend build

FROM nginx:1-alpine
@@ -36,5 +31,3 @@ COPY --from=build /usr/src/app/dist /usr/app
COPY ./frontend/substituteEnv.sh /docker-entrypoint.d/01-substitute-env.sh

EXPOSE 80

# TODO: add entrypoint script to allow changing the VITE_HTTP_HOST and VITE_HTTP_WS at runtime
+3 −10
Original line number Diff line number Diff line
@@ -46,11 +46,9 @@ yarn build
## Docker deployment

Repository has a prepared Dockerfile which can be compiled accordingly. 
The container requires to bind the Frontend to an instance of Backend.
This binding can be done by setting build arguments `VITE_HTTP_HOST` and `VITE_HTTP_WS`

```
docker build . -t inject-fe --build-arg VITE_HTTP_HOST=be.inject.muni.cz --build-arg VITE_HTTP_WS=ws://be.inject.muni.cz/ttxbackend/v1/graphql
docker build . -t inject-fe
```

To deploy the docker container, you only need to execute:
@@ -59,8 +57,7 @@ To deploy the docker container, you only need to execute:
docker run -p 80:80 inject-fe
```

In addition to setting the desired hostname at build-time, it's possible to change it at start-time as well.
This can be done by setting environment variables accordingly. 
During runtime of the container it's required to bind the container to a given `backend` instance. This can be done accordingly

```
docker run -p 80:80 -e VITE_HTTP_HOST=secure-be.inject.muni.cz -e VITE_HTTP_WS=wss://secure-be.inject.muni.cz/ttxbackend/v1/graphql inject-fe
@@ -70,11 +67,7 @@ Please mind, that changing environment variables requires restart of the contain

## How to test the Monorepo

It's expected that you run the backend server for now.

Setup the backend server according to the instruction manual in submoduled backend repository and run it.

Then run `yarn test`, the tests should take no more than a minute now.
Run `yarn test`, the tests should take no more than a minute now.

Currently the testing toolchain is still not very sufficient, this will be remedied in the future. 

+5 −0
Original line number Diff line number Diff line
NGINX_DEFAULT_REQUEST=index.html
NGINX_ROOT=dist
HOST_ADDRESSES='localhost,localhost:5173'
VITE_HTTP_HOST=localhost
VITE_HTTP_WS=ws://localhost/ttxbackend/api/v1/subscription
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
version: '2'

services:
  frontend:
    build:
      context: ../../
      dockerfile: Dockerfile
  backend:
    build:
      context: ../../backend
      dockerfile: Dockerfile
 No newline at end of file
Loading