Skip to content

Commit

Permalink
ci: update traefik configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
GenjiruSUchiwa committed Nov 25, 2024
1 parent 0517d37 commit a24d4c0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}
PROFILE_DB_NAME=${{ secrets.PROFILE_DB_NAME }}
IDENTITY_DB_NAME=${{ secrets.IDENTITY_DB_NAME }}
TRAEFICK_PASSWORD=${{ secrets.TRAEFIK_PASSWORD }}
TRAEFICK_USER=${{ secrets.TRAEFIK_USER }}
SERILOG_APP_NAME=${{ secrets.SERILOG_APP_NAME }}
SERILOG_EXCLUDE_PATH_1=${{ secrets.SERILOG_EXCLUDE_PATH_1 }}
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine AS base
WORKDIR /app

EXPOSE 5000
EXPOSE 443

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
ARG TARGETARCH
Expand Down
98 changes: 56 additions & 42 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,72 @@
version: '3.8'

services:
reverse-proxy:
image: traefik:v3.2.1

traefik:
image: "traefik:v3.2"
container_name: "traefik"
command:
- "--log.level=DEBUG"
- "--accesslog=true"
- "--api.insecure=true"
- "--providers.docker"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.myresolver.acme.email=osscameroon@gmail.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
- "--entrypoints.web.address=:80"
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=aristide.mbassi28@gmail.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
labels:
- "traefik.enable=true"
- "traefik.http.routers.reverse-proxy.rule=Host(`traefik.place.cm`)"
- "traefik.http.routers.reverse-proxy.entrypoints=websecure"
- "traefik.http.routers.reverse-proxy.tls=true"
- "traefik.http.routers.reverse-proxy.tls.certresolver=myresolver"
- "traefik.http.services.reverse-proxy.loadbalancer.server.port=8080"
- "traefik.http.routers.dashboard.rule=Host(`traefik.place.cm`)"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.certresolver=myresolver"
- "traefik.http.middlewares.test-auth.basicauth.users=${TRAEFICK_USER}:${TRAEFICK_PASSWORD}"


ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- lestencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- letsencrypt:/letsencrypt


website:
image: ghcr.io/amacado/docker-landingpage-coming-soon:main
restart: always
container_name: website
labels:
- "traefik.enable=true"

api:
- "traefik.http.routers.website.rule=Host(`place.cm`)"
- "traefik.http.services.website.loadbalancer.server.port=80"
- "traefik.http.routers.website.tls=true"
- "traefik.http.routers.website.tls.certresolver=myresolver"
- "traefik.http.routers.website-www.rule=Host(`www.place.cm`)"
- "traefik.http.routers.website-www.tls=true"
- "traefik.http.routers.website-www.tls.certresolver=myresolver"
- "traefik.http.routers.website-www.entrypoints=websecure"
- "traefik.http.services.website.loadbalancer.server.port=80"
environment:
- TITLE=Place is launching soon..
- META_TITLE=Place - Cameroon | Launching soon!
- SUBTITLE=We are working hard to finish the development of this site.
- FOOTER=<a href='mailto:[email protected]'>[email protected]</a> | <a href='https://www.place.cm'>www.place.cm</a> | <a href='tel:0123456789'>+00 0123 456789</a>
- OVERLAY_COLOR=rgba(0, 0, 0, 0.8)
- BACKGROUND_COLOR=#455A64

place-api:
image: genjirusuchiwa/place:api-latest
user: dotnetuser
container_name: "place-api"
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`api.place.cm`)"
- "traefik.http.routers.api.entrypoints=websecure"
- "traefik.http.routers.api.tls.certresolver=myresolver"
- "traefik.http.services.api.loadbalancer.server.port=5000"
deploy:
mode: replicated
replicas: 3
- "traefik.http.routers.place-api.rule=Host(`api.place.cm`)"
- "traefik.http.routers.place-api.entrypoints=websecure"
- "traefik.http.routers.place-api.tls=true"
- "traefik.http.routers.place-api.tls.certresolver=myresolver"
environment:
- Logging__LogLevel__Default=${LOGGING_LEVEL_DEFAULT:-Information}
- Logging__LogLevel__Microsoft.AspNetCore=${LOGGING_LEVEL_MICROSOFT:-Warning}
Expand Down Expand Up @@ -86,10 +108,9 @@ services:
timeout: 5s
retries: 5
start_period: 40s
networks:
- place-network
restart: always



postgres:
image: postgres:15-alpine
ports:
Expand All @@ -100,21 +121,14 @@ services:
volumes:
- postgres-data:/var/lib/postgresql/data
- ./init-multiple-databases.sh:/docker-entrypoint-initdb.d/init-multiple-databases.sh
networks:
- place-network
healthcheck:
test: pg_isready -U ${POSTGRES_USER}
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
restart: always

networks:
place-network:
driver: bridge


volumes:
lestencrypt:
postgres-data:
name: ${POSTGRES_VOLUME_NAME:-postgres-data}
name: ${POSTGRES_VOLUME_NAME:-postgres-data}
letsencrypt:

0 comments on commit a24d4c0

Please sign in to comment.