From 9bcae836f200cf0a8a0fa805f80fe7c04ebb7fde Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 16 Apr 2023 22:39:23 -0500 Subject: [PATCH] clean up and add migrate container --- .drone.yml | 17 ++---------- Dockerfile | 24 ----------------- flake.nix | 77 ++++++++++++++++++++++++++++-------------------------- uwsgi.ini | 15 ----------- 4 files changed, 42 insertions(+), 91 deletions(-) delete mode 100644 Dockerfile delete mode 100644 uwsgi.ini diff --git a/.drone.yml b/.drone.yml index 5db46fd..6d5d0b6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,21 +15,6 @@ kind: pipeline type: kubernetes name: build steps: - # - name: publish - # image: plugins/kaniko - # pull: always - # settings: - # build_args: - # - VERSION=2.8.1 - # repo: r.ocj.io/network/healthchecks - # registry: r.ocj.io - # username: - # from_secret: local_username - # password: - # from_secret: local_password - # tags: - # - "latest" - # - "${DRONE_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:8}" - name: nixos image: docker.io/jcollie/nixos-runner:latest pull: always @@ -42,6 +27,8 @@ steps: - push-container result --repository network/healthchecks-sendalerts - nix build -L .#maintenance - push-container result --repository network/healthchecks-maintenance + - nix build -L .#migrate + - push-container result --repository network/healthchecks-migrate settings: registry: r.ocj.io username: diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index fde07b9..0000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM python:3.11 - -ARG VERSION - -ENV PYTHONUNBUFFERED=1 - -WORKDIR /opt/healthchecks - -RUN useradd --system hc && \ - git clone --depth 1 --branch v${VERSION} https://github.com/healthchecks/healthchecks.git /opt/healthchecks && \ - pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r /opt/healthchecks/requirements.txt && \ - pip install --no-cache-dir uwsgi && \ - rm -f /opt/healthchecks/hc/local_settings.py && \ - DEBUG=False SECRET_KEY=build-key ./manage.py collectstatic --noinput && \ - DEBUG=False SECRET_KEY=build-key ./manage.py compress - -COPY uwsgi.ini /opt/healthchecks/docker/uwsgi.ini - -USER hc - -VOLUME "/data" -EXPOSE 2525 -EXPOSE 8000 diff --git a/flake.nix b/flake.nix index d00374a..035fa0e 100644 --- a/flake.nix +++ b/flake.nix @@ -108,37 +108,35 @@ }; }; - smtpd = pkgs.dockerTools.buildLayeredImage - ( - pkgs.lib.attrsets.recursiveUpdate baseImage { - name = "healthchecks-smtpd"; - config = { - Cmd = [ - "${self.packages.${system}.healthchecks}/app/manage.py" - "smtpd" - "--port" - "2525" - ]; - ExposedPorts = { - "2525/tcp" = { }; - }; + smtpd = pkgs.dockerTools.buildLayeredImage ( + pkgs.lib.attrsets.recursiveUpdate baseImage { + name = "healthchecks-smtpd"; + config = { + Cmd = [ + "${self.packages.${system}.healthchecks}/app/manage.py" + "smtpd" + "--port" + "2525" + ]; + ExposedPorts = { + "2525/tcp" = { }; }; - } - ); + }; + } + ); - sendalerts = pkgs.dockerTools.buildLayeredImage - ( - pkgs.lib.attrsets.recursiveUpdate baseImage { - name = "healthchecks-sendalerts"; - config = { - Cmd = [ - "${self.packages.${system}.healthchecks}/app/manage.py" - "sendalerts" - ]; - ExposedPorts = { }; - }; - } - ); + sendalerts = pkgs.dockerTools.buildLayeredImage ( + pkgs.lib.attrsets.recursiveUpdate baseImage { + name = "healthchecks-sendalerts"; + config = { + Cmd = [ + "${self.packages.${system}.healthchecks}/app/manage.py" + "sendalerts" + ]; + ExposedPorts = { }; + }; + } + ); maintenance = let @@ -165,6 +163,19 @@ } ); + migrate = pkgs.dockerTools.buildLayeredImage ( + pkgs.lib.attrsets.recursiveUpdate baseImage { + name = "healthchecks-migrate"; + config = { + Cmd = [ + "${self.packages.${system}.healthchecks}/app/manage.py" + "migrate" + ]; + ExposedPorts = { }; + }; + } + ); + webserver = let uwsgi = pkgs.uwsgi.override { @@ -205,14 +216,6 @@ "${uwsgi}/bin/uwsgi" "${uwsgi-ini}" ]; - # Cmd = [ - # "${pkgs.python3Packages.gunicorn}/bin/gunicorn" - # "hc.wsgi" - # "--bind" - # ":8000" - # "--pythonpath" - # self.packages.${system}.healthchecks.pythonPath - # ]; ExposedPorts = { "8000/tcp" = { }; }; diff --git a/uwsgi.ini b/uwsgi.ini deleted file mode 100644 index 63801e4..0000000 --- a/uwsgi.ini +++ /dev/null @@ -1,15 +0,0 @@ -[uwsgi] -master -die-on-term -http-socket = :8000 -harakiri = 10 -post-buffering = 4096 -processes = 4 -enable-threads -threads = 1 -chdir = /opt/healthchecks -module = hc.wsgi:application -thunder-lock -disable-write-exception -static-map = /static=/opt/healthchecks/static-collected -buffer-size = 32768