Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the docker image build #7

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Update gh docker image and triggers

on:
# Triggers the workflow on releases
push:
branches:
- main
tags:
- '*'

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
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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

ENTRYPOINT ["bin/supervisord", "-n"]
14 changes: 14 additions & 0 deletions docker.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[buildout]
extends =
production.cfg

[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
Loading