Skip to content

Commit

Permalink
Added traefik to compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogsilva committed Jun 11, 2024
1 parent 9a67074 commit 6c6842c
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 65 deletions.
8 changes: 0 additions & 8 deletions arpav_ppcv/webapp/api_v2/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from .routers.coverages import router as coverages_router
from .routers.observations import router as observations_router
from .routers.base import router as base_router
from .routers.tileserverproxy import router as tile_server_proxy_router


def create_app(settings: config.ArpavPpcvSettings) -> fastapi.FastAPI:
Expand Down Expand Up @@ -51,11 +50,4 @@ def create_app(settings: config.ArpavPpcvSettings) -> fastapi.FastAPI:
"observations",
],
)
app.include_router(
tile_server_proxy_router,
prefix="/vector-tiles",
tags=[
"vector-tiles",
],
)
return app
54 changes: 0 additions & 54 deletions arpav_ppcv/webapp/api_v2/routers/tileserverproxy.py

This file was deleted.

14 changes: 13 additions & 1 deletion docker/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ x-common-env: &common-env
ARPAV_PPCV__DEBUG: true
ARPAV_PPCV__BIND_HOST: 0.0.0.0
ARPAV_PPCV__BIND_PORT: 5001
ARPAV_PPCV__PUBLIC_URL: http://localhost:5001
ARPAV_PPCV__PUBLIC_URL: http://localhost:8877
ARPAV_PPCV__DB_DSN: postgresql://arpav:arpavpassword@db:5432/arpav_ppcv
ARPAV_PPCV__TEST_DB_DSN: postgresql://arpavtest:arpavtestpassword@test-db:5432/arpav_ppcv_test
ARPAV_PPCV__SESSION_SECRET_KEY: some-key
Expand All @@ -41,6 +41,18 @@ x-common-volumes: &common-volumes

services:

reverse-proxy:
ports:
- target: 80
published: 8877
- target: 8080
published: 8878
command: --configFile /traefik.toml
volumes:
- type: bind
source: $PWD/docker/traefik/dev-config.toml
target: /traefik.toml

webapp:
image: *webapp-image
environment:
Expand Down
17 changes: 15 additions & 2 deletions docker/compose.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,24 @@ name: arpav-ppcv-staging

services:

reverse-proxy:
command: --configFile /opt/traefik/traefik.toml
volumes:
- type: bind
source: home/arpav/docker/traefik/staging-config.toml
target: /opt/traefik/traefik.toml
- type: bind
source: /opt/traefik/certs
target: /opt/traefik/certs

webapp:
env_file:
- *env-file-webapp
labels:
- "traefik.enable=true"
- "traefik.http.routers.arpav-backend.entrypoints=webSecure"
- "traefik.http.routers.arpav-backend.tls=true"
- "traefik.http.routers.arpav-backend.tls.certResolver=letsEncryptResolver"
- "traefik.http.routers.arpav-backend.rule=Host(`arpav.geobeyond.dev`)"
- "traefik.http.services.arpav-backend-service.loadbalancer.server.port=5001"
volumes:
- type: bind
source: $HOME/data/arpav-ppcv/datasets
Expand All @@ -59,6 +67,11 @@ services:
martin:
env_file:
- *env-file-webapp
labels:
- "traefik.http.routers.martin-router.entrypoints=webSecure"
- "traefik.http.routers.martin-router.tls=true"
- "traefik.http.routers.martin-router.tls.certResolver=letsEncryptResolver"
- "traefik.http.routers.martin-router.rule=Host(`arpav.geobeyond.dev`)"
restart: unless-stopped

thredds:
Expand Down
17 changes: 17 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,19 @@ name: arpav-ppcv

services:

reverse-proxy:
image: traefik:3.0.2
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock

webapp:
image: "ghcr.io/geobeyond/arpav-ppcv-backend/arpav-ppcv-backend:latest"
labels:
- "traefik.enable=true"
- "traefik.http.routers.arpav-backend-router.rule=PathRegexp(`^/(api|admin)`)"
- "traefik.http.services.arpav-backend-service.loadbalancer.server.port=5001"
depends_on:
legacy-db:
condition: service_healthy
Expand All @@ -67,6 +78,12 @@ services:

martin:
image: 'ghcr.io/maplibre/martin:v0.13.0'
labels:
- "traefik.enable=true"
- "traefik.http.routers.martin-router.rule=PathPrefix(`/vector-tiles`)"
- "traefik.http.services.martin-service.loadbalancer.server.port=3000"
- "traefik.http.middlewares.strip-martin-prefix-middleware.stripprefix.prefixes=/vector-tiles"
- "traefik.http.routers.martin-router.middlewares=strip-martin-prefix-middleware@docker"
depends_on:
db:
condition: service_healthy
24 changes: 24 additions & 0 deletions docker/traefik/dev-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Static configuration file for traefik
#
# In this file we mostly configure providers, entrypoints and security.
# Routers, the other major part of a traefik configuration, form the
# so-called 'dynamic configuration' and in this case are gotten from
# the labels associated with the docker provider
#
# More info:
#
# https://doc.traefik.io/traefik/

[accessLog]

[entryPoints]
[entryPoints.web]
address = ":80"

[providers]

[providers.docker]
exposedByDefault = false

[api]
insecure = true
34 changes: 34 additions & 0 deletions docker/traefik/staging-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Static configuration file for traefik
#
# In this file we mostly configure providers, entrypoints and security.
# Routers, the other major part of a traefik configuration, form the
# so-called 'dynamic configuration' and in this case are gotten from
# the labels associated with the docker provider
#
# More info:
#
# https://doc.traefik.io/traefik/

[accessLog]

[entryPoints]
[entryPoints.webSecure]
address = ":443"

[entryPoints.webSecure.forwardedHeaders]
insecure = true

[providers]

[providers.docker]
exposedByDefault = false

[certificatesResolvers.letsEncryptResolver.acme]
email = "[email protected]"
storage = "/opt/traefik/certs/acme.json"

# Default: "https://acme-v02.api.letsencrypt.org/directory"
# the default is the production lets encrypt server
# caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"

[certificatesResolvers.letsEncryptResolver.acme.tlsChallenge]

0 comments on commit 6c6842c

Please sign in to comment.