From 09dfe5553b76fa96081cc2da64dc76baf3b9a066 Mon Sep 17 00:00:00 2001 From: kudukm Date: Thu, 9 Apr 2026 19:07:26 +0200 Subject: [PATCH 1/3] Dockerfiles for frontend and backend created and appropriate services in docker-compose.yaml added --- infrastructure/local/docker-compose.yaml | 54 +++++++++++++++++++++++- skyroster-backend/Dockerfile | 17 ++++++++ skyroster-backend/mvnw | 0 skyroster-frontend/Dockerfile | 23 ++++++++++ 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 skyroster-backend/Dockerfile mode change 100644 => 100755 skyroster-backend/mvnw create mode 100644 skyroster-frontend/Dockerfile diff --git a/infrastructure/local/docker-compose.yaml b/infrastructure/local/docker-compose.yaml index 2ad4b7b..d052f75 100644 --- a/infrastructure/local/docker-compose.yaml +++ b/infrastructure/local/docker-compose.yaml @@ -2,6 +2,8 @@ services: postgres: image: postgres:17 container_name: skyroster-db + networks: + - skyroster-network profiles: - db - backend @@ -24,6 +26,8 @@ services: keycloak: image: quay.io/keycloak/keycloak:26.2 container_name: skyroster-keycloak + networks: + - skyroster-network profiles: - backend - full @@ -43,5 +47,53 @@ services: postgres: condition: service_healthy + frontend: + build: + context: ../../skyroster-frontend + args: + VITE_API_URL: http://localhost:8000 + container_name: skyroster-frontend + networks: + - skyroster-network + profiles: + - frontend + - full + ports: + - "5173:80" + volumes: + - ../../skyroster-frontend:/app + - /app/node_modules + restart: unless-stopped + depends_on: + postgres: + condition: service_healthy + keycloak: + condition: service_started + + backend: + build: + context: ../../skyroster-backend + container_name: skyroster-backend + networks: + - skyroster-network + profiles: + - backend + - full + ports: + - "8000:8000" + environment: + SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${DB_NAME:-skyroster} + SPRING_DATASOURCE_USERNAME: ${DB_USERNAME:-skyroster} + SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD:-skyroster} + depends_on: + postgres: + condition: service_healthy + keycloak: + condition: service_started + volumes: - pgdata: \ No newline at end of file + pgdata: + +networks: + skyroster-network: + driver: bridge \ No newline at end of file diff --git a/skyroster-backend/Dockerfile b/skyroster-backend/Dockerfile new file mode 100644 index 0000000..8de5d54 --- /dev/null +++ b/skyroster-backend/Dockerfile @@ -0,0 +1,17 @@ +FROM maven:3-eclipse-temurin-25-alpine AS builder + +WORKDIR /app + +COPY . . + +RUN ./mvnw clean package -DskipTests + +FROM eclipse-temurin:25-jdk-alpine + +WORKDIR /app + +COPY --from=builder /app/target/*.jar app.jar + +EXPOSE 8000 + +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/skyroster-backend/mvnw b/skyroster-backend/mvnw old mode 100644 new mode 100755 diff --git a/skyroster-frontend/Dockerfile b/skyroster-frontend/Dockerfile new file mode 100644 index 0000000..1cfc7f1 --- /dev/null +++ b/skyroster-frontend/Dockerfile @@ -0,0 +1,23 @@ +FROM node:24-alpine +LABEL authors="Bartosz Janusz, Maksymilian Krywionek, Marcin Kuduk, Łukasz Lizak" + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +ARG VITE_API_URL +ENV VITE_API_URL=$VITE_API_URL + +RUN npm run build + +FROM nginx:alpine +COPY --from=0 /app/dist /usr/share/nginx/html +#COPY nginx.conf /etc/nginx/nginx.conf + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file From 2a3b880e8ef97848f85ed6ff8db289b3deb838bb Mon Sep 17 00:00:00 2001 From: kudukm Date: Thu, 9 Apr 2026 19:37:21 +0200 Subject: [PATCH 2/3] Profiles added to docker-compose.yaml, README.md updated --- README.md | 21 ++++++++++++++++----- infrastructure/local/docker-compose.yaml | 2 ++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 492d7c5..392df63 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,26 @@ ## Running locally +### 1. Copy environment file (defaults work out of the box) ```bash -# 1. Copy environment file (defaults work out of the box) cp .env-template .env +``` + +### 2. Start the application + +#### 2.1. Full +```bash +docker compose -f infrastructure/local/docker-compose.yaml --profile full up -d +``` -# 2. Start infrastructure (PostgreSQL + Keycloak) +#### 2.2 Backend + its infrastructure (PostgreSQL + Keycloak) +```bash docker compose -f infrastructure/local/docker-compose.yaml --profile backend up -d +``` -# 3. Backend -cd skyroster-backend -./mvnw spring-boot:run + +#### 2.3 Frontend + its infrastructure (PostgreSQL + Keycloak) +```bash +docker compose -f infrastructure/local/docker-compose.yaml --profile frontend up -d ``` diff --git a/infrastructure/local/docker-compose.yaml b/infrastructure/local/docker-compose.yaml index d052f75..976d1d1 100644 --- a/infrastructure/local/docker-compose.yaml +++ b/infrastructure/local/docker-compose.yaml @@ -6,6 +6,7 @@ services: - skyroster-network profiles: - db + - frontend - backend - full environment: @@ -29,6 +30,7 @@ services: networks: - skyroster-network profiles: + - frontend - backend - full environment: From 007ddb7495bb1cc78409d3e5e37ab8a27738f0d7 Mon Sep 17 00:00:00 2001 From: kudukm Date: Thu, 9 Apr 2026 20:18:07 +0200 Subject: [PATCH 3/3] Squashed commit of the following: commit 25983766fd67d22e1fc4271019f56ba3662bc93d Author: Krywion Date: Wed Apr 8 20:57:27 2026 +0200 ci: fix mvnw permission denied on Linux runner commit 79f8d23b8cb6cbbbb6115ddb58b3a6a4a48d0f47 Author: Krywion Date: Wed Apr 8 20:50:32 2026 +0200 ci: add frontend Dockerfile with nginx and SPA fallback commit cf5dc5e48668b760fde2c31de9445aefa7491a98 Author: Krywion Date: Wed Apr 8 20:47:07 2026 +0200 ci: add backend Dockerfile with multi-stage build commit ea71a9da7147661fd9285a0afdf5cb3dd0c227d9 Author: Krywion Date: Wed Apr 8 20:46:37 2026 +0200 ci: run lint without --fix in CI to detect violations commit 82c5fe477760c4d3ff7276f9b7072bf869bad28e Author: Krywion Date: Wed Apr 8 20:44:11 2026 +0200 ci: add GitHub Actions workflow with build, test and docker jobs # Conflicts: # skyroster-backend/Dockerfile # skyroster-frontend/Dockerfile --- infrastructure/local/docker-compose.yaml | 2 +- skyroster-backend/Dockerfile | 21 ++++++++++++++------- skyroster-frontend/Dockerfile | 13 +++++++------ skyroster-frontend/nginx.conf | 22 ++++++++++++++++++++++ 4 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 skyroster-frontend/nginx.conf diff --git a/infrastructure/local/docker-compose.yaml b/infrastructure/local/docker-compose.yaml index 976d1d1..3747e15 100644 --- a/infrastructure/local/docker-compose.yaml +++ b/infrastructure/local/docker-compose.yaml @@ -82,7 +82,7 @@ services: - backend - full ports: - - "8000:8000" + - "8001:8001" environment: SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/${DB_NAME:-skyroster} SPRING_DATASOURCE_USERNAME: ${DB_USERNAME:-skyroster} diff --git a/skyroster-backend/Dockerfile b/skyroster-backend/Dockerfile index 8de5d54..7461b42 100644 --- a/skyroster-backend/Dockerfile +++ b/skyroster-backend/Dockerfile @@ -1,17 +1,24 @@ -FROM maven:3-eclipse-temurin-25-alpine AS builder +# Stage 1: Build +FROM eclipse-temurin:25-jdk AS build +LABEL authors="Bartosz Janusz, Maksymilian Krywionek, Marcin Kuduk, Łukasz Lizak" WORKDIR /app -COPY . . +# Copy Maven wrapper and POM for dependency caching +COPY .mvn/ .mvn/ +COPY mvnw pom.xml ./ +RUN chmod +x mvnw && ./mvnw dependency:go-offline -B -RUN ./mvnw clean package -DskipTests - -FROM eclipse-temurin:25-jdk-alpine +# Copy source and build (skip tests — they ran in CI job 1) +COPY src/ src/ +RUN ./mvnw package -DskipTests -B +# Stage 2: Runtime +FROM eclipse-temurin:25-jre WORKDIR /app -COPY --from=builder /app/target/*.jar app.jar +COPY --from=build /app/target/*.jar app.jar -EXPOSE 8000 +EXPOSE 8001 ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file diff --git a/skyroster-frontend/Dockerfile b/skyroster-frontend/Dockerfile index 1cfc7f1..259a79a 100644 --- a/skyroster-frontend/Dockerfile +++ b/skyroster-frontend/Dockerfile @@ -1,11 +1,11 @@ -FROM node:24-alpine +# Stage 1: Build +FROM node:22-alpine AS build LABEL authors="Bartosz Janusz, Maksymilian Krywionek, Marcin Kuduk, Łukasz Lizak" WORKDIR /app -COPY package*.json ./ - -RUN npm install +COPY package.json package-lock.json ./ +RUN npm ci COPY . . @@ -14,9 +14,10 @@ ENV VITE_API_URL=$VITE_API_URL RUN npm run build +# Stage 2: Runtime FROM nginx:alpine -COPY --from=0 /app/dist /usr/share/nginx/html -#COPY nginx.conf /etc/nginx/nginx.conf +COPY --from=build /app/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/skyroster-frontend/nginx.conf b/skyroster-frontend/nginx.conf new file mode 100644 index 0000000..5719e3e --- /dev/null +++ b/skyroster-frontend/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # SPA fallback — all routes to index.html + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location /assets/ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Gzip + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml; + gzip_min_length 256; +}