Skip to content

Commit

Permalink
Add the docker image build
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jan 12, 2024
1 parent 39012b8 commit 605377f
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 1 deletion.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
17 changes: 17 additions & 0 deletions docker.cfg
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion redis.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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_}
Expand Down

0 comments on commit 605377f

Please sign in to comment.