diff --git a/docker-compose.yml b/docker-compose.yml index 993c8fb..8360daa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,71 @@ services: # PostgreSQL Database - # User: postgres - # Password: postgres - # Port: 5432 postgres: - image: postgres:17 + image: postgres:17-alpine restart: always container_name: local-postgres - ports: - - "5432:5432" environment: POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres volumes: - postgres_data:/var/lib/postgresql/data + # Auth API - Internal member validation service + auth-api: + build: + context: ./src/Auth + dockerfile: ./AuthAPI/Dockerfile + container_name: auth-api + restart: unless-stopped + # No ports exposed externally + environment: + - ASPNETCORE_ENVIRONMENT=Development + # These should be replaced with real values or set in an .env file + - EnvironmentVariables__ApiUrl=https://sverok-api-url-here + - EnvironmentVariables__ApiKey=YOUR_SVEROK_API_KEY + - EnvironmentVariables__AssociationNumber=YOUR_ASSOCIATION_NUMBER + depends_on: + - postgres + + # Registration API - Core backend service + registration-api: + build: + context: ./src/Registration + dockerfile: ./Registration.API/Dockerfile + container_name: registration-api + restart: unless-stopped + # No ports exposed externally + environment: + - ASPNETCORE_ENVIRONMENT=Development + - ConnectionStrings__DefaultConnection=Host=postgres;Username=postgres;Password=postgres;Database=postgres;Port=5432 + - AuthApi__BaseUrl=http://auth-api:8080 + - VbytesRelay__BaseUrl=https://api.lan.vbytes.se + - VbytesRelay__ApiKey=YOUR_VBYTES_API_KEY + - VbytesRelay__ClientCertificatePfxPath=/app/certs/server.pfx + - Security__SsnPepper=YOUR_SSN_PEPPER + - Admin__Password=admin + volumes: + - ./server.pfx:/app/certs/server.pfx:ro + depends_on: + - postgres + - auth-api + + # Web Frontend - User interface + lan-frontend: + build: + context: ./src/Web/lan-frontend + dockerfile: Dockerfile + args: + - REGISTRATION_API_URL=http://registration-api:8080 + container_name: lan-frontend + restart: always + ports: + - "5000:3000" + environment: + - REGISTRATION_API_URL=http://registration-api:8080 + depends_on: + - registration-api + volumes: postgres_data: diff --git a/src/Auth/AuthAPI/Dockerfile b/src/Auth/AuthAPI/Dockerfile new file mode 100644 index 0000000..c108290 --- /dev/null +++ b/src/Auth/AuthAPI/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build +WORKDIR /app + +# Copy csproj and restore +COPY AuthAPI/AuthAPI.csproj ./AuthAPI/ +RUN dotnet restore AuthAPI/AuthAPI.csproj + +# Copy everything else and build +COPY AuthAPI/. ./AuthAPI/ +WORKDIR /app/AuthAPI +RUN dotnet publish -c Release -o /app/out + +# Runtime stage +FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine +WORKDIR /app +COPY --from=build /app/out . + +EXPOSE 8080 +ENTRYPOINT ["dotnet", "AuthAPI.dll"] diff --git a/src/Registration/Registration.API/Dockerfile b/src/Registration/Registration.API/Dockerfile new file mode 100644 index 0000000..426c646 --- /dev/null +++ b/src/Registration/Registration.API/Dockerfile @@ -0,0 +1,23 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build +WORKDIR /app + +# Copy all project files and restore +COPY Registration.API/Registration.API.csproj ./Registration.API/ +COPY Registration.Infra/Registration.Infra.csproj ./Registration.Infra/ +COPY Registration.Domain/Registration.Domain.csproj ./Registration.Domain/ +RUN dotnet restore Registration.API/Registration.API.csproj + +# Copy all source files and build +COPY Registration.API/. ./Registration.API/ +COPY Registration.Infra/. ./Registration.Infra/ +COPY Registration.Domain/. ./Registration.Domain/ +WORKDIR /app/Registration.API +RUN dotnet publish -c Release -o /app/out + +# Runtime stage +FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine +WORKDIR /app +COPY --from=build /app/out . + +EXPOSE 8080 +ENTRYPOINT ["dotnet", "Registration.API.dll"] diff --git a/src/Web/lan-frontend/Dockerfile b/src/Web/lan-frontend/Dockerfile new file mode 100644 index 0000000..29edb51 --- /dev/null +++ b/src/Web/lan-frontend/Dockerfile @@ -0,0 +1,29 @@ +FROM node:20-alpine AS build +WORKDIR /app + +# Install dependencies +COPY package*.json ./ +RUN npm install + +# Copy source and build +COPY . . +# We don't need these during build if they're runtime, but let's be safe +ARG REGISTRATION_API_URL +ENV REGISTRATION_API_URL=$REGISTRATION_API_URL +RUN npm run build + +# Runtime stage +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=build /app/package*.json ./ +COPY --from=build /app/.next ./.next +COPY --from=build /app/public ./public +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/next.config.ts ./next.config.ts + +EXPOSE 3000 +CMD ["npm", "start"]