Browse Source

Add release engineering files

Arkadiusz Ryś 3 years ago
parent
commit
fcd5661e42
3 changed files with 64 additions and 1 deletions
  1. 10 0
      .dockerignore
  2. 40 1
      .gitlab-ci.yml
  3. 14 0
      Dockerfile

+ 10 - 0
.dockerignore

@@ -0,0 +1,10 @@
+__pycache__/
+*$py.class
+/.git
+/.idea
+/docs
+/data
+/.dockerignore
+/.gitignore
+/.gitlab-ci.yml
+/README.md

+ 40 - 1
.gitlab-ci.yml

@@ -1,11 +1,28 @@
 image: python:latest
+
+variables:
+  DOCKER_DRIVER: overlay2
+  DOCKER_TLS_CERTDIR: "/certs"
+  DOCKER_HOST: tcp://docker:2376
+  # Where to publish this build's tagged working container.
+  DOCKER_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+  DOCKER_BRANCH: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+  DOCKER_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
+  DOCKER_LATEST: $CI_REGISTRY_IMAGE:latest
+
 stages:
   - build
+  - test
+  - release
 
 before_script:
   - python -V
   - echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi"
   - apt-get update && apt-get install -y git
+  - docker info
+  # Because we use a private registry (registry.rys.one), we first need to provide credentials.
+  # This gives us access to pull and push to the registry.
+  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
 
 build-upload:
   stage: build
@@ -16,7 +33,7 @@ build-upload:
   only:
     - tags
 
-build-upload-pypi:
+.build-upload-pypi:
   stage: build
   script:
     - pip install build twine flit
@@ -24,3 +41,25 @@ build-upload-pypi:
     - python -m twine upload dist/*
   only:
     - tags
+
+build_docker:
+  stage: build
+  script:
+    - docker pull $DOCKER_BRANCH || true
+    - docker build --cache-from $DOCKER_BRANCH -f ./Dockerfile --tag $DOCKER_BRANCH .
+    - docker push $DOCKER_BRANCH
+  only:
+    refs:
+      - master
+      - tags
+
+build_tagged_docker:
+  stage: build
+  script:
+    - docker pull $DOCKER_BRANCH || true
+    - docker tag $DOCKER_BRANCH $DOCKER_LATEST
+    - docker push $DOCKER_LATEST
+    - docker tag $DOCKER_BRANCH $DOCKER_TAG
+    - docker push $DOCKER_TAG
+  only:
+    - tags

+ 14 - 0
Dockerfile

@@ -0,0 +1,14 @@
+ARG PYTHON_VERSION=3.11-slim-bullseye
+FROM python:${PYTHON_VERSION}
+ARG APP_HOME=/app
+ENV PYTHONUNBUFFERED 1
+ENV PYTHONDONTWRITEBYTECODE 1
+COPY . ${APP_HOME}
+WORKDIR ${APP_HOME}
+#RUN apt-get update && apt-get install --no-install-recommends -y \
+#  libpq-dev \
+#  && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
+#  && rm -rf /var/lib/apt/lists/*
+RUN pip install requirement.txt
+ENTRYPOINT ["python3 -m ontopoint"]
+#CMD ["/start.sh"]