Make project work with Podman

This commit is contained in:
Mark Veidemanis 2024-12-28 13:20:55 +00:00
parent 6d9c78d2e1
commit 6ccf84be26
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
6 changed files with 144 additions and 53 deletions

View File

@ -197,10 +197,11 @@ CACHES = {
"BACKEND": "django_redis.cache.RedisCache",
# "LOCATION": "unix:///var/run/socks/redis.sock",
"LOCATION": f"redis://{REDIS_HOST}:{REDIS_PORT}",
"LOCATION": "unix:///var/run/redis.sock",
"OPTIONS": {
"db": REDIS_DB,
# "parser_class": "django_redis.cache.RedisCache",
"PASSWORD": REDIS_PASSWORD,
# "PASSWORD": REDIS_PASSWORD,
"pool_class": "redis.BlockingConnectionPool",
},
}

View File

@ -38,11 +38,15 @@ class Command(BaseCommand):
log.debug(f"Scheduling checking process job every {INTERVAL} seconds")
scheduler.add_job(job, "interval", seconds=INTERVAL)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
scheduler._eventloop = loop
scheduler.start()
loop = asyncio.get_event_loop()
try:
loop.run_forever()
except (KeyboardInterrupt, SystemExit):
log.info("Process terminating")
finally:
scheduler.shutdown(wait=False)
loop.close()

View File

@ -12,7 +12,10 @@ services:
- ${PORTAINER_GIT_DIR}:/code
- ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
- fisk_static:${STATIC_ROOT}
# - /code/xf/static:${STATIC_ROOT}
- type: bind
source: /code/run
target: /var/run
#ports:
# - "8000:8000" # uwsgi socket
# Dirty hack for Podman
@ -62,10 +65,17 @@ services:
condition: service_started
collectstatic:
condition: service_started
networks:
- default
- xf
# networks:
# - default
# - xf
# - elastic
#network_mode: "pasta:-T,6380:6379"
deploy:
resources:
limits:
cpus: '0.1'
memory: 0.25G
network_mode: host
scheduling:
image: xf/fisk:prod
@ -79,7 +89,10 @@ services:
- ${PORTAINER_GIT_DIR}:/code
- ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
- fisk_static:${STATIC_ROOT}
# - /code/xf/static:${STATIC_ROOT}
- type: bind
source: /code/run
target: /var/run
# Dirty hack for Podman
environment:
APP_PORT: "${APP_PORT}"
@ -127,10 +140,17 @@ services:
condition: service_started
collectstatic:
condition: service_started
networks:
- default
- xf
# networks:
# - default
# - xf
# - db
#network_mode: "pasta:-T,6380:6379"
deploy:
resources:
limits:
cpus: '0.25'
memory: 0.25G
network_mode: host
migration:
image: xf/fisk:prod
@ -143,7 +163,10 @@ services:
volumes:
- ${PORTAINER_GIT_DIR}:/code
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
- fisk_static:${STATIC_ROOT}
# - /code/xf/static:${STATIC_ROOT}
- type: bind
source: /code/run
target: /var/run
# volumes_from:
# - tmp
# Dirty hack for Podman
@ -184,6 +207,17 @@ services:
REDIS_HOST: "${REDIS_HOST}"
# env_file:
# - stack.env
# networks:
# - default
# - xf
# - db
#network_mode: "pasta:-T,6380:6379"
deploy:
resources:
limits:
cpus: '0.25'
memory: 0.25G
network_mode: host
collectstatic:
image: xf/fisk:prod
@ -196,7 +230,10 @@ services:
volumes:
- ${PORTAINER_GIT_DIR}:/code
- ${APP_DATABASE_FILE}:/conf/db.sqlite3
- fisk_static:${STATIC_ROOT}
# - /code/xf/static:${STATIC_ROOT}
- type: bind
source: /code/run
target: /var/run
# volumes_from:
# - tmp
# Dirty hack for Podman
@ -237,29 +274,53 @@ services:
REDIS_HOST: "${REDIS_HOST}"
# env_file:
# - stack.env
# networks:
# - default
# - xf
# - db
#network_mode: "pasta:-T,6380:6379"
deploy:
resources:
limits:
cpus: '0.25'
memory: 0.25G
network_mode: host
nginx:
image: nginx:latest
container_name: nginx_fisk
ports:
- ${APP_PORT}:9999
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
volumes:
- ${PORTAINER_GIT_DIR}:/code
- ${PORTAINER_GIT_DIR}/docker/nginx/conf.d/${OPERATION}.conf:/etc/nginx/conf.d/default.conf
- fisk_static:${STATIC_ROOT}
# volumes_from:
# - tmp
networks:
- default
- xf
depends_on:
app:
condition: service_started
# nginx:
# image: nginx:latest
# container_name: nginx_fisk
# expose:
# - ${APP_PORT}
# ports:
# - ${APP_PORT}:9999
# # ulimits:
# # nproc: 65535
# # nofile:
# # soft: 65535
# # hard: 65535
# volumes:
# - ${PORTAINER_GIT_DIR}:/code
# - ${PORTAINER_GIT_DIR}/docker/nginx/conf.d/${OPERATION}.conf:/etc/nginx/conf.d/default.conf
# - fisk_static:${STATIC_ROOT}
# - type: bind
# source: /code/run
# target: /var/run
# # volumes_from:
# # - tmp
# # networks:
# # - default
# # - xf
# depends_on:
# app:
# condition: service_started
# # forward the redis port from the host to the container as 6380
# # network_mode: "pasta:-t,9999"
# deploy:
# resources:
# limits:
# cpus: '0.25'
# memory: 0.25G
# network_mode: host
# volumes_from:
@ -280,14 +341,21 @@ services:
image: redis
container_name: redis_fisk
command: redis-server /etc/redis.conf
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
# ulimits:
# nproc: 65535
# nofile:
# soft: 65535
# hard: 65535
volumes:
- ${PORTAINER_GIT_DIR}/docker/redis.conf:/etc/redis.conf
- fisk_redis_data:/data
- type: bind
source: /code/run
target: /var/run
# networks:
# - default
# - xf
# - db
# volumes_from:
# - tmp
healthcheck:
@ -295,6 +363,13 @@ services:
interval: 2s
timeout: 2s
retries: 15
# network_mode: "pasta:-T,6380:6379"
deploy:
resources:
limits:
cpus: '0.25'
memory: 0.25G
network_mode: host
# pyroscope:
# image: "pyroscope/pyroscope:latest"
@ -303,11 +378,11 @@ services:
# command:
# - "server"
networks:
default:
driver: bridge
xf:
external: true
# networks:
# default:
# driver: bridge
# xf:
# external: true
# db:
# external: true

View File

@ -1,6 +1,6 @@
upstream django {
server app:8000;
#server unix:///var/run/socks/app.sock;
#server app:8000;
server unix:///var/run/uwsgi-fisk.sock;
}
server {

View File

@ -1,4 +1,5 @@
# unixsocket /var/run/socks/redis.sock
# unixsocketperm 777
port 6379
requirepass changeme
unixsocket /var/run/redis.sock
unixsocketperm 777
port 0
# port 6379
# requirepass changeme

View File

@ -4,9 +4,19 @@ module=app.wsgi:application
env=DJANGO_SETTINGS_MODULE=app.settings
master=1
pidfile=/tmp/project-master.pid
socket=0.0.0.0:8000
#socket=0.0.0.0:8000
socket=/var/run/uwsgi-fisk.sock
# socket 777
chmod-socket=777
harakiri=20
max-requests=100000
#max-requests=100000
# Set a lower value for max-requests to prevent memory leaks from building up over time
max-requests=1000
# Ensure old worker processes are cleaned up properly
reload-on-as=512
reload-on-rss=256
vacuum=1
home=/venv
processes=12
processes=4
threads=2
log-level=debug