diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..7359d97 --- /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_JOB_NAME_SLUG}-${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..b982712 --- /dev/null +++ b/.gitlab-docker-x86_64.yml @@ -0,0 +1,27 @@ +docker: + variables: + VERSION: latest + DOCKER_HOST: tcp://docker:2375 + + stage: build + + image: docker:latest + services: + - docker:dind + + 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 + - echo -n ${CI_COMMIT_SHORT_SHA} > VERSION + - rm -rf vendor/ database/schema database/seeders database/factories/* + - docker build -f docker/Dockerfile -t ${CI_REGISTRY_IMAGE}:${VERSION} . + - docker push ${CI_REGISTRY_IMAGE}:${VERSION} + tags: + - docker + - x86_64 + only: + - master diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..b780c4a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,10 @@ +FROM registry.dege.au/leenooks/php:8.1-fpm-alpine-pgsql + +COPY . /var/www/html/ + +RUN mkdir -p ${COMPOSER_HOME} && \ + ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true && \ + touch .composer.refresh && \ + mv .env.example .env && \ + FORCE_PERMS=1 NGINX_START=FALSE /sbin/init && \ + rm -rf ${COMPOSER_HOME}/* .git* composer.lock