From 9e415871b5e8f88bafde1af3e6c1bc6472c3f0bf Mon Sep 17 00:00:00 2001 From: M4x1m3 Date: Thu, 20 Apr 2023 17:09:37 +0200 Subject: [PATCH] [ci] Added Dockerfile and building container --- .dockerignore | 2 ++ .github/workflows/ci-workflow.yml | 40 +++++++++++++++++++++++++++++++ Dockerfile | 14 +++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/ci-workflow.yml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..018d87d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +logs/ +config.json diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml new file mode 100644 index 0000000..07be5d8 --- /dev/null +++ b/.github/workflows/ci-workflow.yml @@ -0,0 +1,40 @@ +name: Continuous integration + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + + steps: + - uses: actions/checkout@v3 + + - name: Build image + run: docker build . --file Dockerfile --tag omega-robot + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/omega-robot + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag omega-robot $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b53cd45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Use node lts +FROM python:alpine + +# Set working directory +WORKDIR /omega-robot/ + +# Install dependencies +COPY requirements.pip ./ +RUN pip install -r requirements.pip + +# Build +COPY . ./ + +CMD python3 main.py