43 Commits

Author SHA1 Message Date
b724f4e51c Merge branches 'ci-build-images', 'bug-cannot-autogenerate-self_signed-keys' and 'bug-cannot-start-container' into alt-master 2021-01-01 16:35:03 +01:00
7282cb5fa0 fix: Use correct command name in entrypoint.sh
The generated executable isn't called i2p-tools-1 but reseed-tools.
Without the correct name, the container wouldn't start.
2021-01-01 16:18:33 +01:00
2f8508ee92 ci: Use multiline chomp in YAML
It put the backslashes right into the bash command bash didn't really like that.
Bash escaped spaces and that lead to a bad command
2020-12-29 16:21:29 +01:00
b036b9e8f8 ci: Quote variables properly 2020-12-29 10:47:08 +01:00
f36a500210 ci: Improve tag regex for pushing docker 2020-12-29 10:34:29 +01:00
dbcf640320 ci: Push README to dockerhub 2020-12-29 10:26:48 +01:00
08f2f9031d Add more comments to .gitlab-ci.yml 2020-12-29 01:07:27 +01:00
d40d687f6e ci: limit builds to tags with certain names 2020-12-29 01:05:21 +01:00
b12bf1bf22 docker: ignore IDE files 2020-12-29 00:55:38 +01:00
7bcc9344ec Use correct syntax to ignore folders for docker 2020-12-29 00:54:23 +01:00
f84eb3ce70 retrigger dockerhub build 2020-12-29 00:52:45 +01:00
f576588ec0 Trigger dockerhub build 2020-12-29 00:51:22 +01:00
0ae229792c Ignore .git in docker image 2020-12-29 00:45:16 +01:00
4e69e3d50b Try dockerhub again
There were protected variables involved...
2020-12-29 00:41:53 +01:00
059a24d638 Try to force dockerhub push 2020-12-29 00:30:52 +01:00
45071f0faa Add comments to registry jobs 2020-12-29 00:19:19 +01:00
0791f1145b Don't rebuild image for docker push 2020-12-29 00:15:10 +01:00
51c58d6407 Ninja commit to push new version to dockerhub 2020-12-29 00:01:39 +01:00
0bf519a351 dockerhub build cache from CI_REGISTRY_IMAGE 2020-12-28 23:36:38 +01:00
1eb8e6fb5c Make sure all variables are set before registry push 2020-12-28 23:28:30 +01:00
c4b8236446 Add .gitlab-ci.yml to docker ignore 2020-12-28 22:44:53 +01:00
162c6fb01a Make sure push_docker job only pulls cache
It won't rebuild the image. All it does is push it
2020-12-28 22:35:53 +01:00
11c6b51be6 Ignore and rename CI docker image cache folder from docker build
Images would otherwise include cached docker images
2020-12-28 19:41:13 +01:00
17712bf3ae Try to fix the docker load command
Input needs to come from STDIN
2020-12-28 19:30:46 +01:00
7a438a29ed Create the exports directory to save images 2020-12-28 19:21:34 +01:00
b0cd962ce9 Try using cache instead of local registry
We don't need a server and can just attempt to save the image to later load it.
2020-12-28 19:15:45 +01:00
92462d8986 Name registry in dind and make sure it's running 2020-12-28 18:39:44 +01:00
8d1a4408ce Remove attempt to curl 2020-12-28 18:34:07 +01:00
179688d8c0 Remove dig dep 2020-12-28 18:27:49 +01:00
cb674587f6 Attempt to contact registry service on dind 2020-12-28 18:23:41 +01:00
dc0ec87635 Try using a registry in dind 2020-12-28 18:21:03 +01:00
4c86b4fd8a Hope the dind daemon can connect to the registry... 2020-12-28 17:56:23 +01:00
d48d8e217d Remove docker ps commands 2020-12-28 17:44:44 +01:00
0ac1d8ad65 Try to contact localhost:5000 instead of registry
Hopefully it will have been exposed there (doubtful)
2020-12-28 17:41:05 +01:00
c46fcb14f7 Add correct registry to list of insecure registries 2020-12-28 16:10:47 +01:00
3ec7aace8a Use correct registry name 2020-12-28 16:08:04 +01:00
07b65bee1f Test local registry availability before starting job 2020-12-28 16:07:33 +01:00
1589518259 Re-enable TLS and try to mark local registry as insecure 2020-12-28 16:00:42 +01:00
9fe7931202 Disable TLS to try and make local registry work 2020-12-28 15:45:57 +01:00
8daf43276b Separate docker jobs 2020-12-28 15:39:05 +01:00
2173a6a36e Try and rename local registry image
docker doesn't like "registry:5000:commit_sha" as a tag
2020-12-28 15:32:37 +01:00
f9c992dcb2 Try caching images in a local registry before pushing 2020-12-28 15:27:20 +01:00
fd9eae23eb Build docker images with gitlab CI
These will be pushed to gitlab's CI by default, but can be configured to push to another registry e.g docker hub.
2020-12-28 15:02:04 +01:00
3 changed files with 115 additions and 1 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.idea
.git
.gitlab-ci.yml
.vscode
# CI cache folder storing docker images
ci-exports

106
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,106 @@
image: docker:19.03.12
stages:
- docker_test
- docker_push
variables:
# When using dind service, we need to instruct docker to talk with
# the daemon started inside of the service. The daemon is available
# with a network connection instead of the default
# /var/run/docker.sock socket. Docker 19.03 does this automatically
# by setting the DOCKER_HOST in
# https://github.com/docker-library/docker/blob/d45051476babc297257df490d22cbd806f1b11e4/19.03/docker-entrypoint.sh#L23-L29
#
# The 'docker' hostname is the alias of the service container as described at
# https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#accessing-the-services.
#
# Specify to Docker where to create the certificates, Docker will
# create them automatically on boot, and will create
# `/certs/client` that will be shared between the service and job
# container, thanks to volume mount from config.toml
DOCKER_TLS_CERTDIR: "/certs"
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
services:
- docker:19.03.12-dind
.docker_cache:
cache:
# The same key should be used across branches
key: "$CI_COMMIT_REF_SLUG"
paths:
- ci-exports/*.tar
# Make sure we can build a docker image
# It's cached for later jobs
build_docker:
extends:
- .docker_cache
stage: docker_test
script:
# Try to load latest branch image from local tar or from registry
- docker load ci-exports/$CI_COMMIT_REF_SLUG.tar || docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:latest .
- mkdir -p ci-exports/
- docker save $CI_REGISTRY_IMAGE:latest > ci-exports/$CI_COMMIT_REF_SLUG.tar
# Publishes the configured CI registry (by default that's gitlab's registry)
push_ci_registry:
extends:
- .docker_cache
stage: docker_push
cache:
policy: pull
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- cat ci-exports/$CI_COMMIT_REF_SLUG.tar | docker load
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:latest
only:
refs:
# Make sure to protect these tags!
- /^v(\d+\.){2,3}\d+$/
- /.+-release$/
variables:
- $CI_REGISTRY
- $CI_REGISTRY_USER
- $CI_REGISTRY_PASSWORD
- $CI_REGISTRY_IMAGE
# Publishes the cached image to docker
push_dockerhub_registry:
extends:
- .docker_cache
stage: docker_push
cache:
policy: pull
before_script:
- docker login -u $DOCKERHUB_REGISTRY_USER -p $DOCKERHUB_REGISTRY_PASSWORD $DOCKERHUB_REGISTRY
script:
- cat ci-exports/$CI_COMMIT_REF_SLUG.tar | docker load
- docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_REGISTRY_IMAGE:latest
- docker push $DOCKERHUB_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $DOCKERHUB_REGISTRY_IMAGE:latest
# Push the readme to dockerhub
- >-
docker run -v $PWD:/workspace
-e DOCKERHUB_USERNAME="$DOCKERHUB_REGISTRY_USER"
-e DOCKERHUB_PASSWORD="$DOCKERHUB_REGISTRY_PASSWORD"
-e DOCKERHUB_REPOSITORY="$DOCKERHUB_REGISTRY_IMAGE"
-e README_FILEPATH='/workspace/README.md'
peterevans/dockerhub-description:2
only:
refs:
# Make sure to protect these tags!
- /^v(\d+\.){2,3}\d+$/
- /.+-release$/
variables:
- $DOCKERHUB_REGISTRY
- $DOCKERHUB_REGISTRY_USER
- $DOCKERHUB_REGISTRY_PASSWORD
- $DOCKERHUB_REGISTRY_IMAGE

View File

@@ -2,4 +2,4 @@
cp -r /var/lib/i2p/go/src/i2pgit.org/idk/reseed-tools/content ./content
/var/lib/i2p/go/src/i2pgit.org/idk/reseed-tools/i2p-tools-1 reseed --yes=true --netdb=/var/lib/i2p/i2p-config/netDb $@
/var/lib/i2p/go/src/i2pgit.org/idk/reseed-tools/reseed-tools reseed --yes=true --netdb=/var/lib/i2p/i2p-config/netDb $@