From f9166c9bf2c1bf92303657cd23299e039b63dc5f Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 1 Oct 2022 16:23:25 +1000 Subject: [PATCH] Added gitlab-ci to build docker container --- .gitlab-ci.yml | 14 ++++++++++++++ .gitlab-docker-x86_64.yml | 33 +++++++++++++++++++++++++++++++++ .lumen | 0 Dockerfile | 5 +++++ 4 files changed, 52 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 .gitlab-docker-x86_64.yml create mode 100644 .lumen create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..20bde30 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,14 @@ +stages: +# - test + - build + +# This folder is cached between builds +# http://docs.gitlab.com/ce/ci/yaml/README.html#cache +cache: + key: ${CI_COMMIT_REF_SLUG} + paths: + - vendor/ + +include: +# - .gitlab-test.yml + - .gitlab-docker-x86_64.yml diff --git a/.gitlab-docker-x86_64.yml b/.gitlab-docker-x86_64.yml new file mode 100644 index 0000000..bc6634d --- /dev/null +++ b/.gitlab-docker-x86_64.yml @@ -0,0 +1,33 @@ +docker: + image: docker:latest + + stage: build + + services: + - docker:dind + + variables: + VERSION: latest + CACHETAG: build-${VERSION} + DOCKER_HOST: tcp://docker:2375 + + tags: + - docker + - x86_64 + only: + - master + + before_script: + - docker info + - docker version + - echo "$CI_JOB_TOKEN" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin + - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > auth.json; fi + + script: + - if [ -f init ]; then chmod 500 init; fi + - ([ -z "$REFRESH" ] && docker pull ${CI_REGISTRY_IMAGE}:${CACHETAG}) || echo "true" + - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION + - rm -rf vendor/ database/schema database/seeders database/factories/* + - docker build --cache-from ${CI_REGISTRY_IMAGE}:${CACHETAG} -t ${CI_REGISTRY_IMAGE}:${VERSION} -t ${CI_REGISTRY_IMAGE}:${CACHETAG} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + - docker push ${CI_REGISTRY_IMAGE}:${CACHETAG} diff --git a/.lumen b/.lumen new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1664013 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM registry.leenooks.net/leenooks/php:8.0-fpm-latest + +COPY . /var/www/html/ + +RUN mkdir /var/www/.composer && ([ -r auth.json ] && mv auth.json /var/www/.composer/) || true && touch .composer.refresh && mv .env.example .env && FORCE_PERMS=1 /sbin/init && rm -rf /var/www/.composer/* && touch .migrate