Hello!!
I am having problem with dynamic change of docker file during jobs.
I have two steps in my gitlab-ci.
In one step I would like to add extra line to my project dockerfile.
I was trying to achive this with sed command but it keeps using old file.
In first step I am adding line, in second step I am removing this line.
My gitlab-ci file
stages:
- deploy
- docker
deploy:
image: ilyasemenov/gitlab-ci-git-push
stage: deploy
environment: production
only:
- master
script:
##
## Install ssh-agent if not already installed, it is required by Docker.
## (change apt-get to yum if you use an RPM-based image)
##
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
##
## Run ssh-agent (inside the build environment)
##
- eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
- echo "$SSH_PRIVATE_KEY"
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
##
## Create the SSH directory and give it the right permissions
##
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- sed -i '2 i LABEL com.centurylinklabs.watchtower.enable=false' Dockerfile
- git-push ssh://dokku@my-ip-address:3022/web-example
docker:
image: docker:latest
services:
- docker:dind
stage: docker
environment: production
only:
- master
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- sed -i '2d' Dockerfile
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG