Added docker build configuration

This commit is contained in:
Deon George 2023-03-03 10:36:19 +11:00
parent 32a75cb140
commit a9feaf0a84
3 changed files with 51 additions and 0 deletions

14
.gitlab-ci.yml Normal file
View File

@ -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

27
.gitlab-docker-x86_64.yml Normal file
View File

@ -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

10
docker/Dockerfile Normal file
View File

@ -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