Skip to content

Commit ec111c7

Browse files
authored
Merge branch 'master' into master
2 parents b39d3da + 8ffde06 commit ec111c7

35 files changed

+1794
-474
lines changed

.circleci/config.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
version: 2
2+
jobs:
3+
shellcheck:
4+
docker:
5+
- image: nlknguyen/alpine-shellcheck:v0.4.6
6+
steps:
7+
- checkout
8+
- run:
9+
name: Check Docker Hub Hooks
10+
command: |
11+
find hooks -type f | wc -l
12+
find hooks -type f | xargs shellcheck -e SC2086 --external-sources
13+
- run:
14+
name: Check Scripts
15+
command: |
16+
find . -type f -name '*.sh' | wc -l
17+
find . -type f -name '*.sh' | xargs shellcheck -e SC2086 -e SC1090 --external-sources
18+
19+
build:
20+
docker:
21+
- image: circleci/golang:1-stretch-browsers-legacy
22+
environment:
23+
IMAGE_NAME: "sameersbn/gitlab"
24+
25+
steps:
26+
- checkout
27+
28+
- setup_remote_docker:
29+
version: 18.03.1-ce
30+
31+
- run:
32+
name: Docker info
33+
command: |
34+
docker version
35+
docker info
36+
37+
- restore_cache:
38+
keys:
39+
- cache-v2-{{ .Branch }}
40+
paths:
41+
- /tmp/cache/layers.tar
42+
43+
- run:
44+
name: Loading docker cache
45+
command: |
46+
if [[ -f /tmp/cache/layers.tar ]]; then
47+
echo "Loading cache ..."
48+
docker load -i /tmp/cache/layers.tar
49+
docker image ls
50+
else
51+
echo "Couldn't find any caches"
52+
fi
53+
54+
- run:
55+
name: Build docker image
56+
command: |
57+
docker build \
58+
--pull \
59+
--cache-from=${IMAGE_NAME} \
60+
--build-arg BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")" \
61+
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
62+
-t ${IMAGE_NAME}:$(cat VERSION) .
63+
no_output_timeout: 60m
64+
65+
- run:
66+
name: Launching container for testing
67+
command: |
68+
docker-compose up -d
69+
sleep 180
70+
71+
- run:
72+
name: Testing image
73+
command: |
74+
docker run --network container:$(docker-compose ps -q gitlab) \
75+
appropriate/curl --retry 15 --retry-delay 5 --retry-connrefused http://localhost/explore
76+
77+
- run:
78+
name: Generate docker build image cache
79+
command: |
80+
mkdir -p /tmp/cache/
81+
docker save -o /tmp/cache/layers.tar ${IMAGE_NAME}
82+
83+
- save_cache:
84+
key: cache-v2-{{ .Branch }}
85+
paths:
86+
- /tmp/cache/layers.tar
87+
88+
workflows:
89+
version: 2
90+
build-and-test:
91+
jobs:
92+
- shellcheck
93+
- build

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
*.gem
22
*.tar.gz
33

4-
docker-compose.yml

.gitlab-ci.yml

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
1-
image: docker:dind
1+
image: docker:18-git
22

3-
deploy:
3+
stages:
4+
- build
5+
6+
before_script:
7+
- export VERSION=$(cat VERSION)
8+
- export CI_REGISTRY=${CI_REGISTRY:-hub.docker.com}
9+
- export CI_REGISTRY_USER=${CI_REGISTRY_USER:-gitlab-ci-token}
10+
- export CI_REGISTRY_PASSWORD=${CI_REGISTRY_PASSWORD:-${CI_JOB_TOKEN}}
11+
- export DOCKER_IMAGE=${DOCKER_IMAGE:-${CI_REGISTRY}/${CI_PROJECT_PATH}}
12+
- |
13+
if [ "${DOCKER_IMAGE}" = "/" ]; then
14+
export DOCKER_IMAGE=sameersbn/gitlab
15+
fi
16+
17+
docker:build:
18+
stage: build
19+
only:
20+
- master
21+
script:
22+
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
23+
- docker build
24+
--pull
25+
--cache-from=${DOCKER_IMAGE}
26+
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
27+
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
28+
--tag ${DOCKER_IMAGE} .
29+
- docker push ${DOCKER_IMAGE}
30+
31+
docker:build:branches:
32+
stage: build
33+
only:
34+
- branches
35+
except:
36+
- master
37+
script:
38+
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
39+
- docker build
40+
--pull
41+
--cache-from=${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
42+
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
43+
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
44+
--tag ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG} .
45+
- docker push ${DOCKER_IMAGE}:${CI_COMMIT_REF_SLUG}
46+
47+
docker:build:release:
48+
stage: build
49+
only:
50+
- tags
451
script:
5-
- ci/gitlab
52+
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
53+
- docker build
54+
--pull
55+
--cache-from=${DOCKER_IMAGE}:${VERSION}
56+
--build-arg=VCS_REF=$(git rev-parse --short HEAD)
57+
--build-arg=BUILD_DATE="$(date +"%Y-%m-%d %H:%M:%S%:z")"
58+
--tag ${DOCKER_IMAGE}:${VERSION} .
59+
- docker push ${DOCKER_IMAGE}:${VERSION}

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# GitLab-CI Configuration
2+
3+
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.
4+
5+
Overrides for these values can be set within the project, under `Settings` -> `CI/CD` -> `Variables`.
6+
7+
| Variable | Default Value | Description |
8+
| ---------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
9+
| `CI_REGISTRY` | `hub.docker.com` | If available this will be automatically overriden by registry address which is configured within the GitLab instance |
10+
| `CI_REGISTRY_USER` | `gitlab-ci-token` | Username for the registry |
11+
| `CI_REGISTRY_PASSWORD` | `${CI_JOB_TOKEN}` | Password for the registry |
12+
| `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. |

0 commit comments

Comments
 (0)