mirror of
https://codeberg.org/Freedium-cfd/web.git
synced 2026-03-11 09:04:37 +00:00
docker-compose: enhance container health checks
This commit is contained in:
parent
229d5f0d90
commit
2e0f8bc130
8 changed files with 58 additions and 17 deletions
|
|
@ -1,10 +1,15 @@
|
||||||
# This is the address of the server that will be used to send the requests to
|
# HOST_ADDRESS: Address of the current Freedium instance
|
||||||
HOST_ADDRESS = "http://localhost:6752"
|
HOST_ADDRESS = "http://localhost:6752"
|
||||||
|
|
||||||
# This is the timeout in seconds for the requests
|
# TIMEOUT: Timeout in seconds for the requests
|
||||||
TIMEOUT=3
|
TIMEOUT=3
|
||||||
|
|
||||||
# This is the secret key that will be used to get access for some internal API endpoints
|
# ADMIN_SECRET_KEY: Secret key that will be used to get access for some internal admin API endpoints
|
||||||
ADMIN_SECRET_KEY="test"
|
ADMIN_SECRET_KEY="test"
|
||||||
|
|
||||||
# MEDIUM_AUTH_COOKIES="Get your Medium subscription account coockies here ONLY IF YOU HAVE A PAID SUBSCRIPTION, uid and sid properties is required"
|
# MEDIUM_AUTH_COOKIES="Get your Medium subscription account coockies here ONLY IF YOU HAVE A PAID SUBSCRIPTION, uid and sid properties is required"
|
||||||
|
|
||||||
|
# PROXY_LIST: List of proxies to use for the requests. If not set, the requests will be sent without a proxy
|
||||||
|
# PROXY_LIST=socks5://haproxy-pb:1080
|
||||||
|
|
||||||
|
.... and more values to change you can find in ./web/server/config.py and docker-compose rules folder
|
||||||
|
|
@ -28,6 +28,9 @@ WORKDIR /app/web
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/tmp/poetry_cache poetry install --without dev --only main --no-ansi
|
RUN --mount=type=cache,target=/tmp/poetry_cache poetry install --without dev --only main --no-ansi
|
||||||
|
|
||||||
# EXPOSE 7080
|
RUN apt install -y curl
|
||||||
|
|
||||||
|
RUN useradd -m freedium
|
||||||
|
USER freedium
|
||||||
|
|
||||||
CMD ["python3", "-m", "server", "server"]
|
CMD ["python3", "-m", "server", "server"]
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,10 @@ services:
|
||||||
stop_grace_period: 2m
|
stop_grace_period: 2m
|
||||||
mem_limit: 5g
|
mem_limit: 5g
|
||||||
|
|
||||||
postgres:
|
postgres_freedium:
|
||||||
image: postgres:16.3-alpine3.20
|
image: postgres:16.3-alpine3.20
|
||||||
container_name: freedium_postgres
|
container_name: postgres_freedium
|
||||||
|
hostname: postgres_freedium
|
||||||
networks:
|
networks:
|
||||||
- freedium_net
|
- freedium_net
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -31,6 +32,11 @@ services:
|
||||||
- POSTGRES_PASSWORD=postgres
|
- POSTGRES_PASSWORD=postgres
|
||||||
- POSTGRES_USER=postgres
|
- POSTGRES_USER=postgres
|
||||||
- POSTGRES_DB=postgres
|
- POSTGRES_DB=postgres
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
stop_grace_period: 2m
|
stop_grace_period: 2m
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- freedium_net
|
- freedium_net
|
||||||
- caddy_net
|
- caddy_net
|
||||||
|
restart: always
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD-SHELL", "curl -f http://localhost:6752/ --max-time 80 --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15'" ]
|
test: [ "CMD-SHELL", "curl -f http://localhost:6752/ --max-time 80 --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15'" ]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|
@ -33,18 +34,28 @@ services:
|
||||||
context: ../
|
context: ../
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
environment:
|
environment:
|
||||||
- "PROXY_LIST=socks5://haproxy-pb:1080"
|
- "PROXY_LIST=${PROXY_LIST:-socks5://haproxy-pb:1080}"
|
||||||
depends_on:
|
depends_on:
|
||||||
- haproxy-proxy-balancer
|
haproxy-proxy-balancer:
|
||||||
# volumes:
|
condition: service_healthy
|
||||||
# - ../user_data:/tmp/user_data
|
# postgres_freedium:
|
||||||
# - ./core/medium_parser/:/app/medium_parser
|
# condition: service_healthy
|
||||||
# - ./core/rl_string_helper/:/app/rl_string_helper
|
# volumes:
|
||||||
|
# - ../user_data:/tmp/user_data
|
||||||
|
# - ./core/medium_parser/:/app/medium_parser
|
||||||
|
# - ./core/rl_string_helper/:/app/rl_string_helper
|
||||||
ports:
|
ports:
|
||||||
- "7080:7080"
|
- "7080:7080"
|
||||||
networks:
|
networks:
|
||||||
- freedium_net
|
- freedium_net
|
||||||
mem_limit: 4g
|
mem_limit: 4g
|
||||||
|
restart: always
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "curl -f http://localhost:7080/ --max-time 80 --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15'" ]
|
||||||
|
interval: 30s
|
||||||
|
start_period: 20s
|
||||||
|
timeout: 80s
|
||||||
|
retries: 3
|
||||||
stop_grace_period: 2m
|
stop_grace_period: 2m
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: haproxy-proxy-balancer
|
container_name: haproxy-proxy-balancer
|
||||||
hostname: haproxy-pb
|
hostname: haproxy-pb
|
||||||
ports:
|
# ports:
|
||||||
- "1080:1080"
|
# - "1080:1080"
|
||||||
volumes:
|
volumes:
|
||||||
- ../proxy-balancer/haproxy:/usr/local/etc/haproxy/
|
- ../proxy-balancer/haproxy:/usr/local/etc/haproxy/
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -17,5 +17,15 @@ services:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
wgcf2:
|
wgcf2:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
# dante_1:
|
||||||
|
# condition: service_started
|
||||||
|
# dante_2:
|
||||||
|
# condition: service_started
|
||||||
networks:
|
networks:
|
||||||
- freedium_net
|
- freedium_net
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "nc", "-z", "localhost", "1080" ]
|
||||||
|
interval: 5s
|
||||||
|
# interval: 120s
|
||||||
|
timeout: 15s
|
||||||
|
retries: 3
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,8 @@
|
||||||
FROM haproxy:3.0
|
FROM haproxy:alpine3.20
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN apk add --no-cache netcat-openbsd
|
||||||
|
|
||||||
|
USER haproxy
|
||||||
|
|
||||||
COPY haproxy/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
|
COPY haproxy/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ def wait_for_postgres(max_retries=5, retry_interval=5):
|
||||||
retries = 0
|
retries = 0
|
||||||
while retries < max_retries:
|
while retries < max_retries:
|
||||||
try:
|
try:
|
||||||
conn = connect("postgresql://postgres:postgres@postgres:5432/postgres")
|
conn = connect(config.DATABASE_URL)
|
||||||
conn.close()
|
conn.close()
|
||||||
logger.info("Successfully connected to PostgreSQL")
|
logger.info("Successfully connected to PostgreSQL")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ REDIS_HOST = config("REDIS_HOST", default="redis_service")
|
||||||
REDIS_PORT = config("REDIS_PORT", cast=int, default=6379)
|
REDIS_PORT = config("REDIS_PORT", cast=int, default=6379)
|
||||||
REDIS_TIMEOUT = config("REDIS_TIMEOUT", cast=int, default=1.75)
|
REDIS_TIMEOUT = config("REDIS_TIMEOUT", cast=int, default=1.75)
|
||||||
|
|
||||||
DATABASE_URL = config("DATABASE_URL", default="postgresql://postgres:postgres@postgres:5432/postgres")
|
DATABASE_URL = config("DATABASE_URL", default="postgresql://postgres:postgres@postgres_freedium:5432/postgres")
|
||||||
|
|
||||||
SENTRY_SDK_DSN = config("SENTRY_SDK_DSN", default=None)
|
SENTRY_SDK_DSN = config("SENTRY_SDK_DSN", default=None)
|
||||||
SENTRY_TRACES_SAMPLE_RATE = config("SENTRY_TRACES_SAMPLE_RATE", cast=float, default=0.2)
|
SENTRY_TRACES_SAMPLE_RATE = config("SENTRY_TRACES_SAMPLE_RATE", cast=float, default=0.2)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue