mirror of
https://github.com/sameersbn/docker-gitlab.git
synced 2026-01-18 13:58:25 +00:00
Rewrite CI
UPD .gitlab-ci.yml UPD: Dockerfile UPD: circle-ci.yml DEL: ci/gitlab -> moved to .gitlab-ci.yml ADD: Labels ADD: Docker Daemon build hook ADD: Build Arguments
This commit is contained in:
parent
1f71b9999a
commit
55da4ae7cf
@ -39,7 +39,12 @@ jobs:
|
||||
- run:
|
||||
name: Build docker image
|
||||
command: |
|
||||
docker build --cache-from=${IMAGE_NAME} -t ${IMAGE_NAME} -t ${IMAGE_NAME}:$(cat VERSION) .
|
||||
docker build \
|
||||
--cache-from=${IMAGE_NAME} \
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||
--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
|
||||
|
||||
@ -1,5 +1,54 @@
|
||||
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
|
||||
--build-arg VCS_REF=`git rev-parse --short HEAD`
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
|
||||
--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
|
||||
--build-arg VCS_REF=`git rev-parse --short HEAD`
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
|
||||
--build-arg VERSION=${VERSION}
|
||||
--tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME/\//-} .
|
||||
- docker push ${DOCKER_IMAGE}:${CI_COMMIT_REF_NAME/\//-}
|
||||
|
||||
docker:build:release:
|
||||
stage: build
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASS} ${CI_REGISTRY}
|
||||
- docker build
|
||||
--build-arg VCS_REF=`git rev-parse --short HEAD`
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
|
||||
--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 Gitlan instance with the `${C_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
|
||||
|
||||
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
|
||||
10
hooks/build
Normal file
10
hooks/build
Normal file
@ -0,0 +1,10 @@
|
||||
!/bin/bash
|
||||
|
||||
# Docker Daemon Build Hook
|
||||
# $IMAGE_NAME var is injected into the build so the tag is correct.
|
||||
|
||||
docker build \
|
||||
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
|
||||
--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