Compare commits

...

16 Commits

Author SHA1 Message Date
steinhelge 1ff03552ea config: Adjust Nginx listening address, explicitly set Traefik service ports for dev and prod, and rename the dev connection string key.
Build & Push Hospitality / build-and-push (push) Successful in 4m39s
2025-11-26 21:48:02 +01:00
steinhelge 63eb33a8c9 refactor: enclose CORS policy configuration in a block statement
Build & Push Hospitality / build-and-push (push) Successful in 3m13s
2025-11-26 15:47:06 +01:00
steinhelge f5f56b0407 fix: Correct api service indentation and remove inline comments.
Build & Push Hospitality / build-and-push (push) Failing after 3m19s
2025-11-26 15:36:24 +01:00
steinhelge 0dba448f15 refactor: name CORS policy 'AllowFrontend'
Build & Push Hospitality / build-and-push (push) Failing after 2m57s
2025-11-26 12:43:45 +01:00
steinhelge 072935e133 config: Update API service connection string and add Traefik load balancer port configuration. 2025-11-26 12:41:59 +01:00
steinhelge c3750239c7 feat: configure Traefik load balancer for hospitality-dev-api to use port 8080
Build & Push Hospitality / build-and-push (push) Failing after 3m8s
2025-11-26 12:33:18 +01:00
steinhelge d1568c788a config: Allow all origins in CORS policy and disable HTTPS redirection.
Build & Push Hospitality / build-and-push (push) Failing after 2m4s
2025-11-26 12:07:31 +01:00
steinhelge dcc8e10bd2 config: Expand CORS policy to include development and production frontend URLs.
Build & Push Hospitality / build-and-push (push) Successful in 3m5s
2025-11-26 11:48:38 +01:00
steinhelge 68ecdb0056 feat: Add Nginx configuration for SPA routing and static asset caching.
Build & Push Hospitality / build-and-push (push) Successful in 3m43s
2025-11-25 20:10:47 +01:00
steinhelge bde8e8bedc feat: Integrate Traefik for API and web routing with TLS, updating build workflow to use new HTTPS API endpoints.
Build & Push Hospitality / build-and-push (push) Successful in 3m41s
2025-11-25 20:00:54 +01:00
steinhelge 07af11b541 refactor: move REGISTRY environment variable to job scope and correct step indentation.
Build & Push Hospitality / build-and-push (push) Successful in 2m10s
2025-11-25 19:51:35 +01:00
steinhelge bdfdcbe0f7 Update .gitea/workflows/build.yml 2025-11-25 18:30:14 +00:00
steinhelge 16864584e4 Update .gitea/workflows/build.yml 2025-11-25 18:29:28 +00:00
steinhelge a5ec63b064 Merge pull request 'feat: Configure VITE_API_URL during build via Gitea workflow and Dockerfile, removing local fallback.' (#3) from master into dev
Build & Push Hospitality / build-and-push (push) Successful in 3m40s
Reviewed-on: #3
2025-11-25 18:27:38 +00:00
steinhelge bd64eea849 feat: Configure VITE_API_URL during build via Gitea workflow and Dockerfile, removing local fallback.
Build & Push Hospitality / build-and-push (push) Successful in 3m41s
2025-11-25 19:22:56 +01:00
steinhelge a298159ce2 Update .gitea/workflows/build.yml
Build & Push Hospitality / build-and-push (push) Successful in 2m1s
2025-11-25 12:21:49 +00:00
7 changed files with 93 additions and 43 deletions
+29 -7
View File
@@ -7,12 +7,11 @@ on:
- dev
env:
REGISTRY: gitea.theriise.net/steinhelge
jobs:
build-and-push:
runs-on: self-hosted
env:
REGISTRY: gitea.theriise.net/steinhelge
steps:
- name: Checkout
@@ -45,7 +44,14 @@ jobs:
# ---------- Frontend ----------
- name: Build Frontend (${{ env.TAG }})
run: |
if [ "$TAG" = "dev" ]; then
API_URL="https://hospitality-dev-api.theriise.net/api"
else
API_URL="https://hospitality-api.theriise.net/api"
fi
docker build \
--build-arg VITE_API_URL=$API_URL \
-t $REGISTRY/hospitality-frontend:${TAG} \
-f src/hospitality-web/Dockerfile \
src/hospitality-web
@@ -57,10 +63,10 @@ jobs:
# ---------- Backend API ----------
- name: Build API (${{ env.TAG }})
run: |
docker build \
-t $REGISTRY/hospitality-api:${TAG} \
-f src/Hospitality.Backend/Dockerfile \
.
docker build \
-t $REGISTRY/hospitality-api:${TAG} \
-f src/Hospitality.Backend/Dockerfile \
.
# - name: Build API (${{ env.TAG }})
# run: |
# docker build \
@@ -71,4 +77,20 @@ jobs:
- name: Push API (${{ env.TAG }})
run: |
docker push $REGISTRY/hospitality-api:${TAG}
- name: Deploy containers
run: |
if [ "$TAG" = "dev" ]; then
echo "Deploying DEV til /srv/hospitality-dev"
cd /srv/hospitality-dev
docker compose -p hospitality-dev pull
docker compose -p hospitality-dev up -d
elif [ "$TAG" = "latest" ]; then
echo "Deploying PROD til /srv/hospitality-prod"
cd /srv/hospitality-prod
docker compose -p hospitality-prod pull
docker compose -p hospitality-prod up -d
else
echo "TAG=$TAG er ikke dev eller latest - skipper auto-deploy."
fi
+2 -2
View File
@@ -67,7 +67,7 @@ builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend", policy =>
{
policy.WithOrigins("http://localhost:5173")
policy.SetIsOriginAllowed(origin => true) // Allow any origin
.AllowAnyHeader()
.AllowAnyMethod();
});
@@ -97,7 +97,7 @@ if (app.Environment.IsDevelopment())
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
// app.UseHttpsRedirection(); // Disabled because Traefik handles SSL
app.UseCors("AllowFrontend");
+6
View File
@@ -9,6 +9,9 @@ RUN npm ci
# Kopier resten av koden
COPY . .
ARG VITE_API_URL
ENV VITE_API_URL=$VITE_API_URL
# Bygg for produksjon
RUN npm run build
@@ -19,5 +22,8 @@ WORKDIR /usr/share/nginx/html
# Legg inn bygget frontend
COPY --from=build /app/dist .
# Kopier custom nginx config for SPA routing
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Nginx server som statisk side
EXPOSE 80
@@ -4,6 +4,8 @@ networks:
hospitality-dev-net:
name: hospitality-dev-net
driver: bridge
edge:
external: true
services:
db:
@@ -25,13 +27,19 @@ services:
restart: unless-stopped
environment:
ASPNETCORE_URLS: http://0.0.0.0:8080
ConnectionStrings__Default: "Host=db;Port=5432;Database=hospitality_dev;Username=hospitality_dev;Password=devpassword"
ConnectionStrings__DefaultConnection: "Host=db;Port=5432;Database=hospitality_dev;Username=hospitality_dev;Password=devpassword"
depends_on:
- db
networks:
- hospitality-dev-net
# ports:
# - "5005:8080"
- edge
labels:
- "traefik.enable=true"
- "traefik.docker.network=edge"
- "traefik.http.routers.hospitality-dev-api.rule=Host(`hospitality-dev-api.theriise.net`)"
- "traefik.http.routers.hospitality-dev-api.entrypoints=websecure"
- "traefik.http.routers.hospitality-dev-api.tls=true"
- "traefik.http.services.hospitality-dev-api.loadbalancer.server.port=8080"
web:
image: gitea.theriise.net/steinhelge/hospitality-frontend:dev
@@ -41,18 +49,14 @@ services:
- api
networks:
- hospitality-dev-net
ports:
- "8085:80"
# Eller via Traefik, samme mønster som over:
# networks:
# - hospitality-dev-net
# - edge
# labels:
# - "traefik.enable=true"
# - "traefik.docker.network=edge"
# - "traefik.http.routers.hospitality-dev.rule=Host(`hospitality-dev.theriise.net`)"
# - "traefik.http.routers.hospitality-dev.entrypoints=websecure"
# - "traefik.http.routers.hospitality-dev.tls=true"
- edge
labels:
- "traefik.enable=true"
- "traefik.docker.network=edge"
- "traefik.http.routers.hospitality-dev.rule=Host(`hospitality-dev.theriise.net`)"
- "traefik.http.routers.hospitality-dev.entrypoints=websecure"
- "traefik.http.routers.hospitality-dev.tls=true"
- "traefik.http.services.hospitality-dev.loadbalancer.server.port=80"
volumes:
hospitality-dev-db-data:
@@ -4,6 +4,8 @@ networks:
hospitality-net:
name: hospitality-net
driver: bridge
edge:
external: true
services:
db:
@@ -25,15 +27,19 @@ services:
restart: unless-stopped
environment:
ASPNETCORE_URLS: http://0.0.0.0:8080
# ASP.NET Core-style connection string via env:
ConnectionStrings__Default: "Host=db;Port=5432;Database=hospitality;Username=hospitality;Password=supersecretpassword"
ConnectionStrings__DefaultConnection: "Host=db;Port=5432;Database=hospitality;Username=hospitality;Password=superhemmelig"
depends_on:
- db
networks:
- hospitality-net
# Hvis du vil nå API direkte uten Traefik:
# ports:
# - "5004:8080"
- edge
labels:
- "traefik.enable=true"
- "traefik.docker.network=edge"
- "traefik.http.routers.hospitality-api.rule=Host(`hospitality-api.theriise.net`)"
- "traefik.http.routers.hospitality-api.entrypoints=websecure"
- "traefik.http.routers.hospitality-api.tls=true"
- "traefik.http.services.hospitality-api.loadbalancer.server.port=8080"
web:
image: gitea.theriise.net/steinhelge/hospitality-frontend:latest
@@ -43,19 +49,14 @@ services:
- api
networks:
- hospitality-net
# Ekstern tilgang (uten Traefik):
ports:
- "8084:80"
# Hvis du vil kjøre via Traefik i stedet:
# networks:
# - hospitality-net
# - edge
# labels:
# - "traefik.enable=true"
# - "traefik.docker.network=edge"
# - "traefik.http.routers.hospitality.rule=Host(`hospitality.theriise.net`)"
# - "traefik.http.routers.hospitality.entrypoints=websecure"
# - "traefik.http.routers.hospitality.tls=true"
- edge
labels:
- "traefik.enable=true"
- "traefik.docker.network=edge"
- "traefik.http.routers.hospitality.rule=Host(`hospitality.theriise.net`)"
- "traefik.http.routers.hospitality.entrypoints=websecure"
- "traefik.http.routers.hospitality.tls=true"
- "traefik.http.services.hospitality.loadbalancer.server.port=80"
volumes:
hospitality-db-data:
+17
View File
@@ -0,0 +1,17 @@
server {
listen 0.0.0.0:80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Support for SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Optional: Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, no-transform";
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
import axios from 'axios';
import type { LoginRequest, LoginResponse, UserInfo } from '../types/auth';
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:5163/api';
const API_BASE_URL = import.meta.env.VITE_API_URL;
export const api = axios.create({
baseURL: API_BASE_URL,