Reputation: 193
my docker-compose file like this
services:
database:
container_name: postgres
hostname: db
image: postgres:12-alpine
environment:
- POSTGRES_USER=Database_User
ports:
- "54321:5432"
env_file:
- .env
and when I run CI
on gitlab. As I can't put my .env file on gitlab its giving error Couldn't find env file:
So what is way to use .env
file in gitlab-CI
Upvotes: 1
Views: 1955
Reputation: 686
Unstead of env_file
you can add variable under "settings/ci_cd"
Here an exemple of "docker-compose.yml"
version: '3.3'
services:
var:
image: alpine:latest
command: echo $TEST_VAR
and here my .gitlab-ci.yml
deploy:
stage: deploy
image: docker/compose
script:
- export TEST_VAR=$test_var
- docker-compose up
and here the resulte in the ci:
So just copy all your vars from your .env file into /settins/ci_cd and add export them in script:
before docker-compose up
.
You can read more about variable in CI here.
Upvotes: 1