I am trying to add CI/CD to my django project with docker.
To add CI/CD I found out that I need to create new .env
variable for my docker-compose.yml
service's apps:
NEW_VAR=$CI_REGISTRY/<gitlab username>/<repository name>/custom_image:$CI_ENVIRONMENT_SLUG-$CI_COMMIT_SHA
Added images to apps:
services:
app:
image: ${NEW_VAR}
env_file:
- .env
# ...
bot:
image: ${NEW_VAR}
env_file:
- .env
# ...
Made .gitlab-ci.yml
:
# ...
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- cp $DOT_ENV $(pwd)/.env
# ...
And created and linked runner to my repository. But when I ran docker compose up
on my PC I got error:
WARN[0000] The "lqxwj" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_REGISTRY" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_ENVIRONMENT_SLUG" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_COMMIT_SHA" variable is not set. Defaulting to a blank string.
WARN[0000] The "lqxwj" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_REGISTRY" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_ENVIRONMENT_SLUG" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_COMMIT_SHA" variable is not set. Defaulting to a blank string.
WARN[0000] The "lqxwj" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_REGISTRY" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_ENVIRONMENT_SLUG" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_COMMIT_SHA" variable is not set. Defaulting to a blank string.
WARN[0000] The "lqxwj" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_REGISTRY" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_ENVIRONMENT_SLUG" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_COMMIT_SHA" variable is not set. Defaulting to a blank string.
WARN[0000] The "lqxwj" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_REGISTRY" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_ENVIRONMENT_SLUG" variable is not set. Defaulting to a blank string.
WARN[0000] The "CI_COMMIT_SHA" variable is not set. Defaulting to a blank string.
Error response from daemon: invalid reference format
I can't understand why. .env
in the same diroctory as Dockerfile
, .gitlab-ci.yml
and docker-compose.yml
. Before this NEW_VAR
everything worked fine.
Tried to run docker compose build
and got:
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"lqxwj\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_REGISTRY\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_ENVIRONMENT_SLUG\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_COMMIT_SHA\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"lqxwj\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_REGISTRY\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_ENVIRONMENT_SLUG\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_COMMIT_SHA\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"lqxwj\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_REGISTRY\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_ENVIRONMENT_SLUG\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_COMMIT_SHA\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"lqxwj\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_REGISTRY\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_ENVIRONMENT_SLUG\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_COMMIT_SHA\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"lqxwj\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_REGISTRY\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_ENVIRONMENT_SLUG\" variable is not set. Defaulting to a blank string."
time="2023-04-26T18:45:50+05:00" level=warning msg="The \"CI_COMMIT_SHA\" variable is not set. Defaulting to a blank string."
[+] Building 0.0s (0/0)
invalid tag "/<gitlab username>/<repository name>/custom_image:-": invalid reference format
It doesn't see Gitlab registry variables but how can I start project?