diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5026a5e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +__pycache__/ +*.py[cod] +*.yaml +*.db +*.sublime-project +*.sublime-workspace +.vscode/ +.git/ +.gitignore +Dockerfile +.dockerignore +snap/ +Jenkinsfile +.gitlab-ci.yml +contrib/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..67b0c82 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,56 @@ +# This file is a template, and might need editing before it works on your project. +# To contribute improvements to CI/CD templates, please follow the Development guide at: +# https://docs.gitlab.com/ee/development/cicd/templates.html +# This specific template is located at: +# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml + +# Build a Docker image with CI/CD and push to the GitLab registry. +# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html +# +# This template uses one generic job with conditional builds +# for the default branch and all other (MR) branches. +stages: + - build + +docker-build: + # Use the official docker image. + image: docker:latest + stage: build + services: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + # Default branch leaves tag empty (= latest tag) + # All other branches are tagged with the escaped branch name (commit ref slug) + script: + - | + if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then + tag="" + echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" + else + tag=":$CI_COMMIT_REF_SLUG" + echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" + fi + - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . + - docker push "$CI_REGISTRY_IMAGE${tag}" + # Run this job in a branch where a Dockerfile exists + rules: + - if: $CI_COMMIT_BRANCH + exists: + - Dockerfile + +# snap-build-arm64: +# stage: build +# tags: +# - snap-arm64 +# script: +# - snapcraft +# - snapcraft upload --release=edge *.snap +# +# snap-build-amd64: +# stage: build +# tags: +# - snap-amd64 +# script: +# - snapcraft +# - snapcraft upload --release=edge *.snap diff --git a/Dockerfile b/Dockerfile index 5acd64f..307c7ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,14 @@ -FROM python:3 - -VOLUME /data +FROM python:3.10-slim-bullseye WORKDIR /usr/src/app -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +RUN apt-get update && apt-get install libmagic-dev -y COPY . . +RUN pip install --no-cache-dir -r requirements.txt +ENV CONFIG_FILE=/data/config.yaml +VOLUME /data WORKDIR /data - -EXPOSE 5000/tcp - +EXPOSE 5000 CMD [ "python", "/usr/src/app/pnut-matrix.py", "-d" ]