docker-compose: added traefik
This commit is contained in:
@@ -4,3 +4,4 @@
|
|||||||
.gitignore
|
.gitignore
|
||||||
node_modules
|
node_modules
|
||||||
mongo
|
mongo
|
||||||
|
mongo-volume
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -37,3 +37,4 @@ next-env.d.ts
|
|||||||
postgres
|
postgres
|
||||||
|
|
||||||
mongo
|
mongo
|
||||||
|
mongo-volume
|
||||||
@@ -38,6 +38,7 @@ const authConfig: NextAuthConfig = {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
secret: process.env.AUTH_SECRET,
|
secret: process.env.AUTH_SECRET,
|
||||||
|
trustHost: true, // needs to be set to false for the NextJS to work behing Traefik
|
||||||
session: {
|
session: {
|
||||||
// Use JSON Web Tokens for session instead of database sessions.
|
// Use JSON Web Tokens for session instead of database sessions.
|
||||||
// This option can be used with or without a database for users/accounts.
|
// This option can be used with or without a database for users/accounts.
|
||||||
|
|||||||
@@ -1,19 +1,35 @@
|
|||||||
# this compose file runs Postgres db and exposes it's port to the host machine
|
# this compose file runs Postgres db and exposes it's port to the host machine
|
||||||
version: "3.7"
|
version: "3.7"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
traefik-network:
|
||||||
|
name: "traefik-network"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
web-app:
|
web-app:
|
||||||
image: utility-bills-tracker:1.0.0
|
image: utility-bills-tracker:1.0.0
|
||||||
ports:
|
networks:
|
||||||
- 3000:3000
|
- traefik-network # komunikacija sa Traefikom
|
||||||
environment:
|
environment:
|
||||||
MONGODB_URI: mongodb://root:example@mongo:27017/
|
MONGODB_URI: mongodb://root:example@mongo:27017/
|
||||||
GOOGLE_ID: 355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
|
GOOGLE_ID: 355397364527-adjrokm6hromcaaar0qfhk050mfr35ou.apps.googleusercontent.com
|
||||||
GOOGLE_SECRET: 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
|
GOOGLE_SECRET: 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
|
||||||
AUTH_SECRET: Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
|
AUTH_SECRET: Gh0jQ35oq6DR8HkLR3heA8EaEDtxYN/xkP6blvukZ0w=
|
||||||
HOSTNAME: ${HOSTNAME:-0.0.0.0} # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
|
# HOSTNAME: rezije.localhost # IP address at which the server will be listening (0.0.0.0 = listen on all addresses)
|
||||||
NEXTAUTH_URL: ${NEXTAUTH_URL:-http://localhost:3000} # URL next-auth will use while redirecting user during authentication (if not set - will use HOSTNAME)
|
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}
|
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:
|
mongo:
|
||||||
image: mongo:6.0.12
|
image: mongo:6.0.12
|
||||||
environment:
|
environment:
|
||||||
@@ -23,10 +39,48 @@ services:
|
|||||||
- ./mongo-volume:/data/db
|
- ./mongo-volume:/data/db
|
||||||
mongo-express:
|
mongo-express:
|
||||||
image: mongo-express
|
image: mongo-express
|
||||||
ports:
|
|
||||||
- 8081:8081
|
|
||||||
environment:
|
environment:
|
||||||
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
ME_CONFIG_MONGODB_ADMINUSERNAME: root
|
||||||
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
ME_CONFIG_MONGODB_ADMINPASSWORD: example
|
||||||
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user