mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-18 13:58:25 +00:00
commit
6dc957f06c
@ -18,7 +18,6 @@ jobs:
|
||||
docker version
|
||||
docker info
|
||||
|
||||
|
||||
- restore_cache:
|
||||
keys:
|
||||
- cache-{{ .Branch }}
|
||||
@ -39,19 +38,25 @@ jobs:
|
||||
- run:
|
||||
name: Build docker image
|
||||
command: |
|
||||
docker build --cache-from=${IMAGE_NAME} -t ${IMAGE_NAME} -t ${IMAGE_NAME}:$(cat VERSION) .
|
||||
docker build \
|
||||
--pull \
|
||||
--cache-from=${IMAGE_NAME} \
|
||||
--build-arg BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \
|
||||
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
|
||||
--build-arg VERSION=$(cat VERSION) \
|
||||
-t ${IMAGE_NAME}:$(cat VERSION) .
|
||||
|
||||
- run:
|
||||
name: Launching container for testing
|
||||
command: |
|
||||
docker-compose up -d
|
||||
sleep 10
|
||||
sleep 120
|
||||
|
||||
- run:
|
||||
name: Testing image
|
||||
command: |
|
||||
docker run --network container:$(docker-compose ps -q gitlab) \
|
||||
appropriate/curl --retry 12 --retry-delay 5 --retry-connrefused http://localhost/explore
|
||||
appropriate/curl --retry 15 --retry-delay 5 --retry-connrefused http://localhost/explore
|
||||
|
||||
- run:
|
||||
name: Generate docker build image cache
|
||||
|
||||
@ -1,5 +1,60 @@
|
||||
image: docker:dind
|
||||
image: docker:18-git
|
||||
|
||||
deploy:
|
||||
stages:
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- export VERSION=$(cat VERSION)
|
||||
- export CI_REGISTRY=${CI_REGISTRY:-hub.docker.com}
|
||||
- export CI_REGISTRY_USER=${CI_REGISTRY_USER:-gitlab-ci-token}
|
||||
- export CI_REGISTRY_PASS=${CI_REGISTRY_PASS:-${CI_JOB_TOKEN}}
|
||||
- export DOCKER_IMAGE=${DOCKER_IMAGE:-${CI_REGISTRY}/${CI_PROJECT_PATH}}
|
||||
- |
|
||||
if [ "${DOCKER_IMAGE}" = "/" ]; then
|
||||
export DOCKER_IMAGE=sameersbn/gitlab
|
||||
fi
|
||||
|
||||
docker:build:
|
||||
stage: build
|
||||
only:
|
||||
- master
|
||||
script:
|
||||
- ci/gitlab
|
||||
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASS} ${CI_REGISTRY}
|
||||
- docker build
|
||||
--pull
|
||||
--cache-from=${DOCKER_IMAGE}
|
||||
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
|
||||
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
|
||||
--build-arg=VERSION=${VERSION}
|
||||
--tag ${DOCKER_IMAGE} .
|
||||
- docker push ${DOCKER_IMAGE}
|
||||
|
||||
docker:build:branches:
|
||||
stage: build
|
||||
only:
|
||||
- branches
|
||||
script:
|
||||
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASS} ${CI_REGISTRY}
|
||||
- docker build
|
||||
--pull
|
||||
--cache-from=${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
|
||||
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
|
||||
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
|
||||
--build-arg=VERSION=${VERSION}
|
||||
--tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG} .
|
||||
- docker push ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
|
||||
|
||||
docker:build:release:
|
||||
stage: build
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASS} ${CI_REGISTRY}
|
||||
- docker build
|
||||
--pull
|
||||
--cache-from=${DOCKER_IMAGE}:${VERSION}
|
||||
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
|
||||
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
|
||||
--build-arg=VERSION=${VERSION}
|
||||
--tag ${DOCKER_IMAGE}:${VERSION} .
|
||||
- docker push ${DOCKER_IMAGE}:${VERSION}
|
||||
|
||||
12
CONTRIBUTING.md
Normal file
12
CONTRIBUTING.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Gitlab-CI Configuration
|
||||
|
||||
When using your own gitlab instance, the provided .gitlab-ci.yml will be automatically be using the settings provided by the Gitlab Instance. If needed several options can be overriden.
|
||||
|
||||
Overrides for these values can be set within the project, under `Settings` -> `CI/CD` -> `Variables`.
|
||||
|
||||
| Variable | Default Value | Description |
|
||||
| ------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `CI_REGISTRY` | `hub.docker.com` | If available this will be automatically overriden by registry address which is configured within the Gitlab instance |
|
||||
| `CI_REGISTRY_USER` | `gitlab-ci-token` | Username for the registry |
|
||||
| `CI_REGISTRY_PASS` | `${CI_JOB_TOKEN}` | Password for the registry |
|
||||
| `DOCKER_IMAGE` | `sameersbn/gitlab` | Docker image name, will be automatically be overriden by the running Gitlab instance with the `${CI_PROJECT_PATH}` variable. This will case the image to be uploaded to the local registry of the project within Gitlab. |
|
||||
17
Dockerfile
17
Dockerfile
@ -1,8 +1,21 @@
|
||||
FROM ubuntu:xenial-20181005
|
||||
|
||||
LABEL maintainer="sameer@damagehead.com"
|
||||
ARG BUILD_DATE
|
||||
ARG VCS_REF
|
||||
ARG VERSION=11.4.5
|
||||
|
||||
ENV GITLAB_VERSION=11.4.5 \
|
||||
LABEL \
|
||||
maintainer="sameer@damagehead.com" \
|
||||
org.label-schema.schema-version="1.0" \
|
||||
org.label-schema.build-date=${BUILD_DATE} \
|
||||
org.label-schema.name=gitlab \
|
||||
org.label-schema.vendor=damagehead \
|
||||
org.label-schema.url="https://github.com/sameersbn/docker-gitlab" \
|
||||
org.label-schema.vcs-url="https://github.com/sameersbn/docker-gitlab.git" \
|
||||
org.label-schema.vcs-ref=${VCS_REF} \
|
||||
com.damagehead.gitlab.license=MIT
|
||||
|
||||
ENV GITLAB_VERSION=${VERSION} \
|
||||
RUBY_VERSION=2.4 \
|
||||
GOLANG_VERSION=1.10.4 \
|
||||
GITLAB_SHELL_VERSION=8.3.3 \
|
||||
|
||||
15
ci/gitlab
15
ci/gitlab
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
VERSION=$(cat VERSION)
|
||||
DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST:-hub.docker.com}
|
||||
DOCKER_IMAGE=${DOCKER_IMAGE:-sameersbn/gitlab}
|
||||
|
||||
docker build -t $DOCKER_IMAGE .
|
||||
|
||||
docker tag $DOCKER_IMAGE $DOCKER_REGISTRY_HOST/$DOCKER_IMAGE:latest
|
||||
docker tag $DOCKER_IMAGE $DOCKER_REGISTRY_HOST/$DOCKER_IMAGE:$VERSION
|
||||
|
||||
docker push $DOCKER_REGISTRY_HOST/$DOCKER_IMAGE:latest
|
||||
docker push $DOCKER_REGISTRY_HOST/$DOCKER_IMAGE:$VERSION
|
||||
12
hooks/build
Normal file
12
hooks/build
Normal file
@ -0,0 +1,12 @@
|
||||
!/bin/bash
|
||||
|
||||
# Docker Daemon Build Hook
|
||||
# $IMAGE_NAME var is injected into the build so the tag is correct.
|
||||
|
||||
docker build \
|
||||
--pull \
|
||||
--cache-from=${IMAGE_NAME} \
|
||||
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \
|
||||
--build-arg=VCS_REF=$(git rev-parse --short HEAD) \
|
||||
--build-arg=VERSION=$(cat VERSION) \
|
||||
-t ${IMAGE_NAME} .
|
||||
Loading…
x
Reference in New Issue
Block a user