Skip to content

Commit

Permalink
Dockerisation
Browse files Browse the repository at this point in the history
  • Loading branch information
shibijm committed Sep 12, 2023
1 parent 62a20e0 commit a412311
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dockerignore
.git
.github
Dockerfile
19 changes: 0 additions & 19 deletions .github/workflows/build-and-release.yml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release
run-name: Release ${{ inputs.version || github.ref_name }}
on:
push:
tags:
- v*
workflow_dispatch:
inputs:
version:
required: true
type: string
description: Version (vX.X.X)
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
VERSION: ${{ inputs.version || github.ref_name }}
RELEASE_ZIP_FILENAME: ${{ github.event.repository.name }}-${{ inputs.version || github.ref_name }}.zip
DOCKER_IMAGE_NAME: ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create release ZIP file
run: zip -r $RELEASE_ZIP_FILENAME . -x /.git/* -x /.github/* -x /.dockerignore -x /Dockerfile
- name: Delete existing GitHub release, if any
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: gh release delete $VERSION --cleanup-tag --yes || true
- name: Release on GitHub
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
with:
tag_name: ${{ env.VERSION }}
generate_release_notes: true
files: ${{ env.RELEASE_ZIP_FILENAME }}
- name: Delete release ZIP file
run: rm $RELEASE_ZIP_FILENAME
- name: Sign into GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ env.VERSION }},${{ env.DOCKER_IMAGE_NAME }}:latest
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-alpine
ARG USERNAME=app
ARG USER_UID=10000
ARG USER_GID=$USER_UID
RUN addgroup -g $USER_GID $USERNAME && adduser -u $USER_UID -G $USERNAME -D $USERNAME
USER $USERNAME
WORKDIR /app
COPY --chown=$USERNAME:$USERNAME requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir
COPY --chown=$USERNAME:$USERNAME . .
CMD ["python", "main.py"]
EXPOSE 22334

0 comments on commit a412311

Please sign in to comment.