Skip to content
Snippets Groups Projects
Commit f1e72235 authored by Jiri Sadek's avatar Jiri Sadek
Browse files

Merge branch '30-docker'

parents c831951d 0be5aaad
No related branches found
No related tags found
No related merge requests found
# Ignore everything
*
# Except for these files
!/check
!/orderedsql.sh
!/sql
!/upgrades
!/LICENSE
!/README.rst
stages:
- build
variables:
DOCKER_REGISTRY: "reg.office.nic.cz"
workflow:
auto_cancel:
on_new_commit: interruptible
########################################################################################################################
# Individual jobs
docker:
stage: build
before_script:
- docker login --username "$DOCKER_USERNAME" --password "$DOCKER_TOKEN" "$DOCKER_REGISTRY"
script:
- FRED_DB_TAG="$IMAGE_TAG" docker compose build --no-cache --pull --push fred_db
# Only push `latest` when commit tag is the latest tag in the repository
- last_git_tag="$(git tag | grep -Ex '[0-9]+.[0-9]+.[0-9]+' | sort -Vr | head -n1)"
- if [ "$last_git_tag" = "$CI_COMMIT_TAG" ]; then FRED_DB_TAG="latest" docker compose build --push fred_db; fi
tags:
- dind
variables:
COMPOSE_FILE: "docker/devel/compose.yml"
needs: []
rules:
- if: $CI_COMMIT_TAG
variables:
IMAGE_TAG: "$CI_COMMIT_TAG"
- if: $CI_COMMIT_BRANCH == "master"
variables:
IMAGE_TAG: "master"
# Ignore everything
*
# Except for these files
!/entrypoint-initdb.d
FROM postgres:13
COPY --from=config ./entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
COPY ./ /app
WORKDIR /app
services:
fred_db:
image: reg.office.nic.cz/fred/db:${FRED_DB_TAG:-latest}
build:
context: ../..
dockerfile: docker/devel/Dockerfile
additional_contexts:
config: .
#!/bin/bash
set -e
echo $PWD
dsn="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB"
psql -v ON_ERROR_STOP=1 "$dsn" <<-EOSQL
CREATE DATABASE ${POSTGRES_FRED_DB:-fred};
EOSQL
#!/bin/bash
set -e
echo $PWD
dsn="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/$POSTGRES_DB"
psql -v ON_ERROR_STOP=1 "$dsn" <<-EOSQL
CREATE USER ${POSTGRES_FRED_USER:-fred} WITH PASSWORD '${POSTGRES_FRED_PASSWORD:-password}';
GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_FRED_DB:-fred} TO ${POSTGRES_FRED_USER:-fred};
EOSQL
#!/bin/bash
set -e
echo $PWD
dsn="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST/${POSTGRES_FRED_DB:-fred}"
psql -v ON_ERROR_STOP=1 "$dsn" <<-EOSQL
CREATE EXTENSION pgcrypto;
CREATE EXTENSION pg_trgm;
CREATE EXTENSION unaccent;
EOSQL
#!/bin/bash
set -e
echo "$PWD"
dsn="postgresql://${POSTGRES_FRED_USER:-fred}:${POSTGRES_FRED_PASSWORD:-password}@$POSTGRES_HOST/${POSTGRES_FRED_DB:-fred}"
WITH_LOGGER=${WITH_LOGGER:-1}
if [[ "$WITH_LOGGER" -eq 1 ]]; then
/bin/bash ./orderedsql.sh | psql -v ON_ERROR_STOP=1 "$dsn"
else
/bin/bash ./orderedsql.sh --without-log | psql -v ON_ERROR_STOP=1 "$dsn"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment