diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ad1ddff --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Update gh docker image and triggers + +on: + # Triggers the workflow on releases + push: + branches: + - main + tags: + - '*' + pull_request: + # Allow to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build-image: + name: Build docker image + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get the image id + run: | + IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]') + echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_ENV" + + - name: Get the version PR + run: echo "VERSION=${{ github.head_ref }}" >> "$GITHUB_ENV" + if: github.event_name == 'pull_request' + + - name: Get the version + run: echo "VERSION=${{ github.ref_name }}" >> "$GITHUB_ENV" + if: github.event_name != 'pull_request' + + - name: Build and push container image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ env.IMAGE_ID }}:${{ env.VERSION }} + platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b2d60c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.8 + +WORKDIR /app + +COPY . . + +RUN apt-get update && \ + pip install -r requirements.txt && \ + buildout -N -c docker.cfg && \ + sed -i 's/bind 127.0.0.1 ::1/bind 0.0.0.0/g' ./etc/redis.conf + +EXPOSE 4000/tcp + +HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost:4020/ || exit 1 + +ENTRYPOINT ["bin/supervisord", "-n"] diff --git a/docker.cfg b/docker.cfg new file mode 100644 index 0000000..6d7c38b --- /dev/null +++ b/docker.cfg @@ -0,0 +1,17 @@ +[buildout] +extends = + production.cfg + +# parts -= +# ${redis:parts} + +[supervisor] +recipe = collective.recipe.supervisor +http-socket = unix +user = admin +password = admin +file = ${buildout:directory}/var/supervisor.sock +programs = + 100 dispatcher ${buildout:directory}/bin/gunicorn [-w 4 -b 0.0.0.0:${ports:gunicorn} production:app] ${buildout:directory} true + 200 redis (killasgroup=true stopasgroup=true) ${buildout:directory}/bin/redis-server true + 300 rq ${buildout:directory}/bin/rq [worker --url redis://127.0.0.1:${ports:redis}] ${buildout:directory} true diff --git a/redis.cfg b/redis.cfg index bafd71e..b0775cb 100644 --- a/redis.cfg +++ b/redis.cfg @@ -8,7 +8,7 @@ parts= redis-conf recipe = hexagonit.recipe.cmmi -url=http://download.redis.io/releases/redis-4.0.10.tar.gz +url=https://github.com/redis/redis/archive/7.2.4.tar.gz configure-command = true make-options = PREFIX=${buildout:parts-directory}/${:_buildout_section_name_}