diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 10cb7fc8..3e9874a1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,19 +34,11 @@ jobs: --username ${{ secrets.PYPI_USERNAME }} \ --password ${{ secrets.PYPI_PASSWORD }} - - name: Docker meta server - id: meta_server + - name: Docker meta + id: meta uses: docker/metadata-action@v3 with: - images: aparcar/asu-server - tags: | - type=semver,pattern={{version}} - - - name: Docker meta worker - id: meta_worker - uses: docker/metadata-action@v3 - with: - images: aparcar/asu-worker + images: aparcar/asu tags: | type=semver,pattern={{version}} @@ -56,18 +48,10 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push ASU server to Docker Hub - uses: docker/build-push-action@v2 - with: - file: Dockerfile.server - push: true - tags: ${{ steps.meta_server.outputs.tags }} - labels: ${{ steps.meta_server.outputs.labels }} - - - name: Build and push ASU worker to Docker Hub + - name: Build and push ASU to Docker Hub uses: docker/build-push-action@v2 with: - file: Dockerfile.worker + file: Containerfile push: true - tags: ${{ steps.meta_worker.outputs.tags }} - labels: ${{ steps.meta_worker.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.gitignore b/.gitignore index e01c0d67..04fd1af3 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ instance/ json/ poetry.lock public/ +redis/ site/ store/ var/ diff --git a/Containerfile b/Containerfile new file mode 100644 index 00000000..1a8a6321 --- /dev/null +++ b/Containerfile @@ -0,0 +1,16 @@ +FROM python:3.10-slim + +WORKDIR /app/ + +RUN pip install poetry + +COPY poetry.lock pyproject.toml ./ + +RUN poetry config virtualenvs.create false \ + && poetry install --only main --no-interaction --no-ansi + +COPY ./asu/ ./asu/ + +COPY ./misc/config.py /etc/asu/config.py + +CMD gunicorn 'asu.asu:create_app()' --bind 0.0.0.0:8000 diff --git a/Dockerfile.server b/Dockerfile.server deleted file mode 100644 index ff028e5c..00000000 --- a/Dockerfile.server +++ /dev/null @@ -1,19 +0,0 @@ -FROM python:3.10-slim - -RUN useradd -c "OpenWrt Builder" -m -d /home/build -s /bin/bash build - -USER build - -RUN mkdir /home/build/asu/ - -WORKDIR /home/build/asu/ - -COPY ./misc/config.py /etc/asu/config.py - -RUN pip install --no-cache-dir gunicorn asu - -ENV PATH="/home/build/.local/bin:${PATH}" - -CMD /bin/sh -c 'gunicorn "asu.asu:create_app()" --bind 0.0.0.0:8000' - -EXPOSE 8000 diff --git a/Dockerfile.worker b/Dockerfile.worker deleted file mode 100644 index b94b5d85..00000000 --- a/Dockerfile.worker +++ /dev/null @@ -1,19 +0,0 @@ -FROM openwrt/imagebuilder - -ENV REDIS_HOST="redis://redis" - -RUN mkdir /home/build/asu/ - -WORKDIR /home/build/asu/ - -RUN sudo apt-get -q update \ - && sudo apt-get install -y python3-pip \ - && sudo apt-get clean autoclean \ - && sudo apt-get autoremove --yes \ - && sudo rm -rf /var/lib/{apt,dpkg,cache,log}/ - -RUN pip3 install --no-cache-dir rq asu - -ENV PATH="/home/build/.local/bin:${PATH}" - -CMD /bin/sh -c 'rqworker --url "$REDIS_HOST"' diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8d14a2b0..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,43 +0,0 @@ -version: "2" - -services: - server: - image: "aparcar/asu-server:latest" - environment: - - REDIS_HOST=redis - volumes: - - "./asu-service:/home/build/asu/" - ports: - - "8000" - depends_on: - - redis - - janitor: - image: "aparcar/asu-server:latest" - environment: - - FLASK_APP=asu.asu - - FLASK_DEBUG=1 - - REDIS_HOST=redis - command: flask janitor update - volumes: - - "./asu-service:/home/build/asu/" - depends_on: - - redis - - worker: - image: "aparcar/asu-worker:latest" - volumes: - - "./asu-service/public/:/home/build/asu/public/" - depends_on: - - redis - - redis: - image: "redis:alpine" - - webserver: - image: caddy - volumes: - - "./misc/Caddyfile:/etc/caddy/Caddyfile" - - "./asu-service:/site/" - ports: - - "8000:80" diff --git a/podman-compose.yml b/podman-compose.yml new file mode 100644 index 00000000..256a549b --- /dev/null +++ b/podman-compose.yml @@ -0,0 +1,62 @@ +version: "2" +volumes: + podman-sock: + redis: +services: + server: + image: "aparcar/asu:latest" + environment: + - REDIS_HOST=redis + volumes: + - "./asu-service/public/:/app/public/" + ports: + - "127.0.0.1:8000:8000" + depends_on: + - redis + + janitor: + image: "aparcar/asu:latest" + environment: + - FLASK_APP=asu.asu + - FLASK_DEBUG=1 + - REDIS_HOST=redis + command: flask janitor update + volumes: + - "./asu-service/public/:/app/public/" + depends_on: + - redis + + worker: + image: "aparcar/asu:latest" + command: rqworker --url "redis://redis" + environment: + - CONTAINER_HOST=unix:///tmp/socket/podman.sock + volumes: + - ./asu-service/public/:/app/public/ + - podman-sock:/tmp/socket/ + depends_on: + - redis + - podman + + podman: + image: quay.io/podman/stable + user: podman + volumes: + - podman-sock:/tmp/socket/ + command: sh -c "mkdir -p /tmp/socket && podman system service --time=0 unix:///tmp/socket/podman.sock" + + redis: + image: "redis:alpine" + volumes: + - redis:/data/ + +# Podman may not allow ports 1024, consider using an external web server +# webserver: +# image: caddy +# volumes: +# - "./misc/Caddyfile:/etc/caddy/Caddyfile" +# - "./asu-service:/site/" +# ports: +# - "8000:8081" +# depends_on: +# - server