Merge commit '25948cf033f213cf90cb19f261a63eca8504b46d'

This commit is contained in:
2024-01-15 14:05:00 +01:00
2 changed files with 62 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ const authConfig: NextAuthConfig = {
}),
],
secret: process.env.AUTH_SECRET,
trustHost: true, // needs to be set to false for the NextJS to work behing Traefik
session: {
// Use JSON Web Tokens for session instead of database sessions.
// This option can be used with or without a database for users/accounts.

View File

@@ -1,21 +1,35 @@
# this compose file runs Postgres db and exposes it's port to the host machine
version: "3.7"
networks:
traefik-network:
name: "traefik-network"
services:
web-app:
image: utility-bills-tracker:1.0.2
ports:
- ${PORT:-3001}:80
volumes:
- ./etc/hosts:/etc/hosts
networks:
- traefik-network # komunikacija sa Traefikom
environment:
MONGODB_URI: mongodb://root:example@mongo:27017/
GOOGLE_ID: 355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
GOOGLE_SECRET: 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
AUTH_SECRET: Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
HOSTNAME: ${HOSTNAME:-rezije.app} # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
NEXTAUTH_URL: ${NEXTAUTH_URL:-https://rezije.app} # URL next-auth will use while redirecting user during authentication (if not set - will use HOSTNAME)
PORT: 80
# HOSTNAME: rezije.localhost # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
EXTAUTH_URL: ${HOSTNAME:-http://rezije.localhost:3000) # URL next-auth will use while redirecting user during authentication (if not set - will use HOSTNAME)
PORT: ${PORT:-3000}
deploy:
# u slucaju rušenja kontejnera čekamo 5s i dižemo novi kontejner => ako se i on sruši opet ceka 5s i pokusava ponovno (tako 5 puta)
restart_policy:
condition: any
delay: 5s
max_attempts: 0 # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.web-app.loadbalancer.server.port=3000
- traefik.http.routers.web-app.entrypoints=http
- traefik.http.routers.web-app.rule=Host(`${FQDN:-rezije.localhost)`)
mongo:
image: mongo:4.4.27
environment:
@@ -25,10 +39,48 @@ services:
- ./mongo-volume:/data/db
mongo-express:
image: mongo-express
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
networks:
- traefik-network # komunikacija sa Traefikom
deploy:
# u slucaju rušenja kontejnera čekamo 5s i dižemo novi kontejner => ako se i on sruši opet ceka 5s i pokusava ponovno (tako 5 puta)
restart_policy:
condition: any
delay: 5s
max_attempts: 0 # u slučaju rušenja containera pokušavaj ga pokrenuti dok ne uspije = BESKONAČNO
labels:
- traefik.enable=true
- traefik.docker.network=traefik-network # mreže preko koje ide komunikacija sa Traefikom
- traefik.http.services.mongo-express.loadbalancer.server.port=8001
- traefik.http.routers.mongo-express.entrypoints=http
- traefik.http.routers.mongo-express.rule=Host(`mongo.localhost`)
reverse-proxy:
image: traefik:v2.3
command:
# Traefik web konzoli se pristupa preko HTTP, a ne HTTPS
- --api.insecure=true
- --providers.docker
# activates the Swarm Mode (instead of standalone Docker).
# - kada je `false` neće detektirati containere kada se pokrene sa `docker-compose up`
- --providers.docker.swarmMode=true
# prikazuj samo containere koji su nakačeni na Traefik
- --providers.docker.exposedByDefault=false
# "ping" omogućujemo za potrebe healthcheck-a
- --ping=true
- --ping.entryPoint=traefik
#- --accesslog=true
#- --log.level=DEBUG
- --entryPoints.http.address=:3000
ports:
- "3001:3000"
- "8080:8080"
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
networks:
- traefik-network