Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/.gitlab-ci.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ fetch:
- git fetch --all
- git checkout ${NEW_HEAD}
- sops -d ci.secrets.docker-compose.yml > secrets.docker-compose.yml
- ./bin/generate_env
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate_env => generate_ci_env

needs: ["prebuild"]

build:
Expand All @@ -144,15 +145,6 @@ build:
# ak build then docker build
- cd ~gitlab-runner/builds/${AK_WORKING_DIR}

- cp .env-ci .env
# TODO use copier or something to inialize this env variables
- echo BUILD_NAME=${BUILD_NAME} >> .env
- echo CI_PROJECT_NAME=${CI_PROJECT_NAME} >> .env
- echo "DOMAIN=${DOMAIN}" >> .env
# uid , gid used by docker in postgres to fix perms on .db
- echo "UID=`id -u`" >> .env
- echo "GID=`id -g`" >> .env

# ak build
- cd odoo && time ak clone && time ak sparse && time ak build && cd ..

Expand Down Expand Up @@ -308,10 +300,6 @@ test:
script:
- CURRENT_PATH=`pwd`
- cd ~gitlab-runner/builds/${AK_WORKING_DIR}
- cp .env .env-test
- echo "ENABLE_TRAEFIK=false" >> .env-test
- echo "COMPOSE_PROJECT_NAME=${BUILD_NAME}_test" >> .env-test
- echo "PGDATABASE=${BUILD_NAME}_test" >> .env-test
- docker compose --env-file .env-test kill
- dropdb --force --if-exists ${BUILD_NAME}_test
- docker compose --env-file .env-test run --rm odoo initdb ${BUILD_NAME}_test --cache-prefix ${CI_PROJECT_NAME:0:7}
Expand Down
26 changes: 26 additions & 0 deletions src/bin/generate_env
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -euxo pipefail

# generate env file (env, .env-test)
# Usage:
# ./generate_env

echo "generate env file"
cp .env-ci .env
# uid , gid used by docker in postgres to fix perms on .db
cat << EOF >> .env
BUILD_NAME=${BUILD_NAME}
CI_PROJECT_NAME=${CI_PROJECT_NAME}
DOMAIN=${DOMAIN}
UID=`id -u`
GID=`id -g`
EOF

cp .env .env-test
echo "PGDATABASE=${BUILD_NAME}" >> .env

cat << EOF >> .env
ENABLE_TRAEFIK=false
COMPOSE_PROJECT_NAME=${BUILD_NAME}_test
PGDATABASE=${BUILD_NAME}_test
EOF