I am trying to write a docker-compose.yml
which is then used in a continuous integration pipeline, but should also be possible to use locally.
I naively tried this:
services:
app:
build:
...
image: ${IMAGE_SERVER_URL:-}/image_name:${IMAGE_TAG:-latest}
in my gitlab-ci.yml
I log into the image server:
echo ${IMAGE_SERVER_PASSWORD} | docker login -u ${IMAGE_SERVER_USERNAME} --password-stdin ${IMAGE_SERVER_URL}
and then I can do
docker-compose build --pull
docker-compose push
So what is the issue?
when the .devcontainer
from vscode attempts to build the app I get ERROR: Invalid Reference Format
which is of course due to the fact that
/image-name:latest
is not a valid image name. So the issue is the slash.
docker-compose
does not accept ${IMAGE_SERVER_URL+/}
currently (cf. docker docs) so that is out of the question. I could of course include the slash in the environment variable but I have the feeling that this is going to cause similar problems in other places.
Are there any best practices when it comes to formatting dynamic image names?