From b16db665e56059a1a4035fee78b2566adac2afcb Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 23 Jan 2025 11:32:13 +0000 Subject: [PATCH] Update to work with Podman --- .gitignore | 3 +- Dockerfile | 10 +-- Makefile | 2 +- docker-compose.prod.yml | 164 ++++++++++++++++++--------------- docker-compose.yml | 194 ---------------------------------------- 5 files changed, 99 insertions(+), 274 deletions(-) delete mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index b63f740..76873fb 100644 --- a/.gitignore +++ b/.gitignore @@ -58,7 +58,6 @@ cover/ # Django stuff: *.log -local_settings.py db.sqlite3 db.sqlite3-journal @@ -156,3 +155,5 @@ cython_debug/ .bash_history .python_history .vscode/ +stack.env + diff --git a/Dockerfile b/Dockerfile index 439fb21..1f98816 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,17 +2,17 @@ FROM python:3 ARG OPERATION -RUN useradd -d /code pathogen +RUN useradd -d /code xf RUN mkdir -p /code -RUN chown -R pathogen:pathogen /code +RUN chown -R xf:xf /code RUN mkdir -p /conf/static -RUN chown -R pathogen:pathogen /conf +RUN chown -R xf:xf /conf RUN mkdir /venv -RUN chown pathogen:pathogen /venv +RUN chown xf:xf /venv -USER pathogen +USER xf ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 WORKDIR /code diff --git a/Makefile b/Makefile index c683cd3..1131484 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ stop: docker-compose -f docker-compose.prod.yml --env-file=stack.env down log: - docker-compose -f docker-compose.prod.yml --env-file=stack.env logs -f + docker-compose -f docker-compose.prod.yml --env-file=stack.env logs -f --names migrate: docker-compose -f docker-compose.prod.yml --env-file=stack.env run --rm app sh -c ". /venv/bin/activate && python manage.py migrate" diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index a8e9ffc..c6a1e41 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -2,7 +2,7 @@ version: "2.2" services: app: - image: pathogen/neptune:latest + image: xf/neptune:latest container_name: neptune build: context: . @@ -11,9 +11,11 @@ services: volumes: - ${PORTAINER_GIT_DIR}:/code - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py + #- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} + - type: bind + source: /code/run + target: /var/run # env_file: # - stack.env environment: @@ -96,13 +98,14 @@ services: condition: service_started collectstatic: condition: service_started - networks: - - default - - xf - - db + # networks: + # - default + # - xf + # - db + network_mode: host processing: - image: pathogen/neptune:latest + image: xf/neptune:latest container_name: processing_neptune build: context: . @@ -112,9 +115,11 @@ services: volumes: - ${PORTAINER_GIT_DIR}:/code - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py + #- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} + - type: bind + source: /code/run + target: /var/run environment: # General application settings APP_PORT: "${APP_PORT}" @@ -197,13 +202,14 @@ services: condition: service_started collectstatic: condition: service_started - networks: - - default - - xf - - db + # networks: + # - default + # - xf + # - db + network_mode: host scheduling: - image: pathogen/neptune:latest + image: xf/neptune:latest container_name: scheduling_neptune build: context: . @@ -213,9 +219,11 @@ services: volumes: - ${PORTAINER_GIT_DIR}:/code - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py + #- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} + - type: bind + source: /code/run + target: /var/run environment: # General application settings APP_PORT: "${APP_PORT}" @@ -298,13 +306,14 @@ services: condition: service_started collectstatic: condition: service_started - networks: - - default - - xf - - db + # networks: + # - default + # - xf + # - db + network_mode: host migration: - image: pathogen/neptune:latest + image: xf/neptune:latest container_name: migration_neptune build: context: . @@ -313,9 +322,11 @@ services: command: sh -c '. /venv/bin/activate && python manage.py migrate --noinput' volumes: - ${PORTAINER_GIT_DIR}:/code - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py + #- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} + - type: bind + source: /code/run + target: /var/run environment: # General application settings APP_PORT: "${APP_PORT}" @@ -394,13 +405,14 @@ services: depends_on: redis: condition: service_healthy - networks: - - default - - xf - - db + # networks: + # - default + # - xf + # - db + network_mode: host collectstatic: - image: pathogen/neptune:latest + image: xf/neptune:latest container_name: collectstatic_neptune build: context: . @@ -409,9 +421,11 @@ services: command: sh -c '. /venv/bin/activate && python manage.py collectstatic --noinput' volumes: - ${PORTAINER_GIT_DIR}:/code - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py + #- ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} + - type: bind + source: /code/run + target: /var/run # volumes_from: # - tmp environment: @@ -490,33 +504,34 @@ services: depends_on: redis: condition: service_healthy - networks: - - default - - xf - - db + # networks: + # - default + # - xf + # - db + network_mode: host - nginx: - image: nginx:latest - container_name: nginx_neptune - 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 - - neptune_static:${STATIC_ROOT} - # volumes_from: - # - tmp - networks: - - default - - xf - depends_on: - app: - condition: service_started + # nginx: + # image: nginx:latest + # container_name: nginx_neptune + # 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 + # - neptune_static:${STATIC_ROOT} + # # volumes_from: + # # - tmp + # networks: + # - default + # - xf + # depends_on: + # app: + # condition: service_started # tmp: # image: busybox @@ -529,14 +544,17 @@ services: image: redis container_name: redis_neptune 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 - neptune_redis_data:/data + - type: bind + source: /code/run + target: /var/run # volumes_from: # - tmp healthcheck: @@ -544,18 +562,18 @@ services: interval: 2s timeout: 2s retries: 15 - networks: - - default - - xf + # networks: + # - default + # - xf -networks: - default: - driver: bridge - xf: - external: true - db: - external: true +# networks: +# default: +# driver: bridge +# xf: +# external: true +# db: +# external: true volumes: - neptune_static: {} + # neptune_static: {} neptune_redis_data: {} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index f7d9781..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,194 +0,0 @@ -version: "2.2" - -services: - app: - image: pathogen/neptune:latest - container_name: neptune - build: - context: . - args: - OPERATION: ${OPERATION} - volumes: - - ${PORTAINER_GIT_DIR}:/code - - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} - env_file: - - stack.env - volumes_from: - - tmp - depends_on: - redis: - condition: service_healthy - migration: - condition: service_started - collectstatic: - condition: service_started - networks: - - default - - pathogen - - elastic - - processing: - image: pathogen/neptune:latest - container_name: processing_neptune - build: - context: . - args: - OPERATION: ${OPERATION} - command: sh -c '. /venv/bin/activate && python manage.py processing' - volumes: - - ${PORTAINER_GIT_DIR}:/code - - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} - env_file: - - stack.env - volumes_from: - - tmp - depends_on: - redis: - condition: service_healthy - migration: - condition: service_started - collectstatic: - condition: service_started - networks: - - default - - pathogen - - elastic - - scheduling: - image: pathogen/neptune:latest - container_name: scheduling_neptune - build: - context: . - args: - OPERATION: ${OPERATION} - command: sh -c '. /venv/bin/activate && python manage.py scheduling' - volumes: - - ${PORTAINER_GIT_DIR}:/code - - ${PORTAINER_GIT_DIR}/docker/uwsgi.ini:/conf/uwsgi.ini - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} - env_file: - - stack.env - volumes_from: - - tmp - depends_on: - redis: - condition: service_healthy - migration: - condition: service_started - collectstatic: - condition: service_started - networks: - - default - - pathogen - - elastic - - migration: - image: pathogen/neptune:latest - container_name: migration_neptune - build: - context: . - args: - OPERATION: ${OPERATION} - command: sh -c '. /venv/bin/activate && python manage.py migrate --noinput' - volumes: - - ${PORTAINER_GIT_DIR}:/code - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} - volumes_from: - - tmp - depends_on: - redis: - condition: service_healthy - - collectstatic: - image: pathogen/neptune:latest - container_name: collectstatic_neptune - build: - context: . - args: - OPERATION: ${OPERATION} - command: sh -c '. /venv/bin/activate && python manage.py collectstatic --noinput' - volumes: - - ${PORTAINER_GIT_DIR}:/code - - ${APP_LOCAL_SETTINGS}:/code/app/local_settings.py - - ${APP_DATABASE_FILE}:/conf/db.sqlite3 - - neptune_static:${STATIC_ROOT} - volumes_from: - - tmp - env_file: - - stack.env - depends_on: - redis: - condition: service_healthy - - nginx: - image: nginx:latest - container_name: nginx_neptune - 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 - - neptune_static:${STATIC_ROOT} - volumes_from: - - tmp - networks: - - default - - pathogen - depends_on: - app: - condition: service_started - - tmp: - image: busybox - container_name: tmp_neptune - command: chmod -R 777 /var/run/socks - volumes: - - /var/run/socks - - redis: - image: redis - container_name: redis_neptune - command: redis-server /etc/redis.conf - ulimits: - nproc: 65535 - nofile: - soft: 65535 - hard: 65535 - volumes: - - ${PORTAINER_GIT_DIR}/docker/redis.conf:/etc/redis.conf - volumes_from: - - tmp - healthcheck: - test: "redis-cli -s /var/run/socks/redis.sock ping" - interval: 2s - timeout: 2s - retries: 15 - networks: - - default - - pathogen - -networks: - default: - driver: bridge - pathogen: - external: true - elastic: - external: true - -volumes: - neptune_static: {} \ No newline at end of file