Skip to content

Commit

Permalink
Merge pull request #243 from NIAEFEUP/chore/prepare-for-niployments
Browse files Browse the repository at this point in the history
chore: prepare for niployments
  • Loading branch information
tomaspalma authored Aug 14, 2024
2 parents 4090bef + e4bddd4 commit 1d7b230
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 31 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/niployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy

on:
push:
branches:
- main
- develop

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Upload to NIployments register
uses: NIAEFEUP/[email protected]
with:
docker_dockerfile: Dockerfile
docker_context: .
docker_target: prod
docker_build_args: |
TTS_FE_VARS_METHOD=content-var
TTS_FE_VARS_CONTENT=${{ secrets.TTS_FE_VARS_CONTENT }}
NIPLOYMENTS_REGISTRY_URL: ${{ vars.NIPLOYMENTS_REGISTRY_URL }}
NIPLOYMENTS_REGISTRY_USERNAME: ${{ vars.NIPLOYMENTS_REGISTRY_USERNAME }}
NIPLOYMENTS_REGISTRY_PASSWORD: ${{ secrets.NIPLOYMENTS_REGISTRY_PASSWORD }}
31 changes: 30 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM node:21-alpine3.19
ARG TTS_FE_VARS_METHOD=dotenv

# build
FROM node:21-alpine3.19 AS build

RUN mkdir -p /usr/src/tts-fe
WORKDIR /usr/src/tts-fe
Expand All @@ -15,6 +18,32 @@ COPY public/ public/
COPY src/ src/
COPY index.html ./

# dev
FROM build AS dev

EXPOSE $PORT

CMD ["npm", "run", "dev"]

# prod-build-with-dotenv
FROM build AS prod-build-with-dotenv

ARG TTS_FE_DOTENV_FILE=.env.production
COPY ${TTS_DOTENV_FILE} .env.production

# prod-build-with-var
FROM build AS prod-build-with-content-var

ARG TTS_FE_VARS_CONTENT
RUN echo "${TTS_FE_VARS_CONTENT}" | base64 -d > .env.production

# prod-build
FROM prod-build-with-${TTS_FE_VARS_METHOD} AS prod-build
RUN npm run build

# prod
FROM nginx:alpine AS prod

COPY --from=prod-build /usr/src/tts-fe/build /usr/share/nginx/html
COPY nginx.tts.conf /etc/nginx/conf.d/default.conf

26 changes: 0 additions & 26 deletions Dockerfile.prod

This file was deleted.

9 changes: 5 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
container_name: tts_frontend
build:
context: .
target: dev
volumes:
- ./src:/usr/src/tts-fe/src
- ./public:/usr/src/tts-fe/public
Expand All @@ -15,12 +16,12 @@ services:
container_name: tts_frontend_prod
build:
context: .
dockerfile: Dockerfile.prod
target: prod
args:
- TTS_FE_VARS_METHOD=dotenv
- TTS_FE_DOTENV_FILE=.env
volumes:
- ./src:/usr/src/tts-fe/src
- ./public:/usr/src/tts-fe/public
ports:
- 3100:80
env_file:
- .env

0 comments on commit 1d7b230

Please sign in to comment.