Merge branch 'feat/auto-build-and-deploy-web-app'

feat(web-app): added CI to build docker image CD to deploy the app

See merge request team-raclette/project-softweng!12
This commit is contained in:
2025-05-20 14:38:04 +02:00
4 changed files with 28 additions and 3 deletions

View File

@@ -1,2 +1,3 @@
include:
- local: gateway/.gitlab-ci.yml
- local: web-app/.gitlab-ci.yml

View File

@@ -102,7 +102,7 @@ services:
- "traefik.http.services.mqtt-https.loadbalancer.server.port=1883"
web-app:
image: web-app:1.0
image: registry.forge.hefr.ch/team-raclette/project-softweng/web-app:latest
container_name: web-app
restart: unless-stopped
ports:
@@ -121,3 +121,5 @@ services:
- "traefik.http.routers.web-app-https.rule=Host(`app.mse.kb28.ch`)"
- "traefik.http.routers.web-app-https.tls.certResolver=letsencrypt"
- "traefik.http.services.web-app-https.loadbalancer.server.port=8080"
- "com.centurylinklabs.watchtower.enable=true"

22
web-app/.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,22 @@
variables:
DOCKER_IMAGE: registry.forge.hefr.ch/team-raclette/project-softweng/web-app:latest
default:
image: $DOCKER_IMAGE
stages:
- build-docker
docker-build:
image: docker:latest
stage: build-docker
services:
- docker:dind
script:
- docker build -t $DOCKER_IMAGE -f web-app/Dockerfile .
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker push $DOCKER_IMAGE
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_BRANCH == 'main'
- changes:
- web-app/*

View File

@@ -2,7 +2,7 @@ FROM node:22.15-slim
WORKDIR /app
COPY . .
COPY ./web-app .
RUN npm install