ci(build): Added docker container build job

Builds the container and pushes to local gitlab registry

MR !1
This commit is contained in:
2022-02-14 13:15:18 +09:30
parent b01bab033f
commit f80c02ba15
2 changed files with 99 additions and 0 deletions

View File

@ -27,12 +27,86 @@ Markdown Linting:
extends:
- .Lint_Markdown
Docker Container:
stage: build
image: docker:latest
services:
- docker:19.03.12-dind
before_script:
- docker info
# - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- apk update
- apk add --update --no-cache python3 git && ln -sf python3 /usr/bin/python
- python3 -m ensurepip
- pip3 install -r gitlab-ci/gitlab_release/requirements.txt
- pip3 install gitlab-ci/gitlab_release/python-module/cz_nfc/.
script: |
docker build . \
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
--label org.opencontainers.image.documentation="$CI_PROJECT_URL/pages" \
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
--label org.opencontainers.image.url="$CI_PROJECT_URL/-/releases/v$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.version="$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
--no-cache \
--tag $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA;
docker image inspect $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA;
docker push $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA;
# after_script:
# - docker push $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA
rules:
- if: $CI_COMMIT_TAG
when: on_success
- if: '$CI_COMMIT_BRANCH != "master"'
when: manual
- when: never
Gitlab Release:
extends:
- .gitlab_release
Docker Hub:
stage: publish
image: docker:latest
services:
- docker:19.03.12-dind
before_script:
- export
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker pull $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA
- docker logout $CI_REGISTRY
script:
# - Release_TAG=$(cat $CI_PROJECT_DIR/dist/version)
- docker login docker.io -u $NFC_DOCKERHUB_USERNAME -p $NFC_DOCKERHUB_TOKEN
# - if [ "m$(echo $CI_BUILD_REF_NAME | grep rc)" == "m$CI_BUILD_REF_NAME" ]; then Branch_TAG=dev; else Branch_TAG=stable; fi
- echo Branch tag is $Branch_TAG
- docker image ls
- docker image tag $CI_REGISTRY_IMAGE/docker-mail:$CI_COMMIT_SHA nofusscomputing/docker-mail:$CI_COMMIT_TAG
- docker image ls
- docker push nofusscomputing/docker-mail:$CI_COMMIT_TAG
rules:
- if: $CI_COMMIT_TAG
when: on_success
- if: $CI_MERGE_REQUEST_IID
when: never
- if: '$CI_COMMIT_BRANCH'
when: never
needs: [ "Docker Container" ]
environment:
name: DockerHub
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
Github (Push --mirror):
variables:
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/docker-mail.git"

View File

@ -1,6 +1,22 @@
FROM debian:bullseye-slim
LABEL \
#org.opencontainers.image.created="" \ # set during build with $(date --rfc-3339=seconds) \
org.opencontainers.image.authors="No Fuss Computing" \
#org.opencontainers.image.url="" # $CI_PROJECT_URL/-/releases/$CI_COMMIT_TAG set during build from url\
#org.opencontainers.image.documentation="" # $CI_PROJECT_URL/pages Set URL during build \
#org.opencontainers.image.source="" # $CI_PROJECT_URL Set URL during build \
#org.opencontainers.image.version="" \ # $(cz -n cz_nfc version --project) ) Set during build from .cz.yml
#org.opencontainers.image.revision="" # $CI_COMMIT_SHA set during build from git commit \
org.opencontainers.image.vendor="No Fuss Computing" \
#License(s) under which contained software is distributed as an SPDX License Expression.
org.opencontainers.image.licenses="" \
org.opencontainers.image.title="No Fuss Computings docker mail server" \
org.opencontainers.image.description="A Complete mailserver in a container"
# Install dependencies
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y --no-install-recommends install \
curl \
@ -170,3 +186,12 @@ EXPOSE 25 587 993 4190
ENTRYPOINT ["/docker-entrypoint.sh"]
# testing software
RUN apt update && DEBIAN_FRONTEND=noninteractive apt -y --no-install-recommends install \
procps \
vim \
iputils-ping \
python3-ldap
# && freshclam