I want to write e2e tests, the doc says https://docs.gitlab.com/ee/ci/services/#available-settings-for-services that each service can have its own variables, but my runner doesn't have this functionality yet, because i have other version
so, this code is work
test-e2e:
image: gitlab-registry.xx.ru/golang/go:1.18
services:
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db-1
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db-2
variables:
POSTGRES_DB: database
POSTGRES_USER: database
POSTGRES_PASSWORD: database
but i want have database with other dbnames, this code don't work
test-e2e:
image: gitlab-registry.xx.ru/golang/go:1.18
services:
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db
variables:
POSTGRES_DB: database
POSTGRES_USER: database
POSTGRES_PASSWORD: database
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db-1
variables:
POSTGRES_DB: database-1
POSTGRES_USER: database
POSTGRES_PASSWORD: database
- name: gitlab-registry.xx.ru/docker/postgres:latest
alias: db-2
variables:
POSTGRES_DB: database-2
POSTGRES_USER: database
POSTGRES_PASSWORD: database
is it possible to pass POSTGRES_DB through command or entrypoint?
This does not work in gitlab, I redid the tests on dind
Related
I have to deploy postgresql:12 with postgis and agensgraph extensions using docker-compose.
Separetely they are installed well, here is my yml file:
for postgis
docker-compose.base.yml
version: '3.4'
services:
db:
image: postgis/postgis:12-3.2-alpine
ports:
- "7001:5432"
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
command: postgres -c listen_addresses='*' -c max_connections=200
restart: always
for agensgraph
docker-compose.base.yml
version: '3.4'
services:
db:
image: docker.io/bitnine/agensgraph:v2.12.0_rc-debian
ports:
- "7001:5432"
command: postgres -c listen_addresses='\*' -c max_connections=200
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- /custom/mount:/var/lib/postgresql/data
restart: always
How to deploy postgresql:12 with postgis and agensgraph extensions in one docker-compose?
I'm using bitnami's Keycloak v.20.0.0 (Quarkus) image with docker-compose. Everything works fine and I have no problems with any configuration, however when I want to see the tables in the PostgreSQL database, I access without problems but I don't see anything! I don't see that any table or database exists.
I understand that I have to start Keycloak in dev mode which I configured but I still don't see anything.
What am I doing wrong?
this is my setup:
version: "3.7"
services:
keycloak:
image: bitnami/keycloak:20.0.1
container_name: keycloak_20
environment:
DB_VENDOR: POSTGRES
DB_ADDR: postgres
KEYCLOAK_ADMIN_USER: admin
KEYCLOAK_ADMIN_PASSWORD: admin
KEYCLOAK_DATABASE_HOST: postgres
KEYCLOAK_DATABASE_PORT: 5432
KEYCLOAK_DATABASE_NAME: postgres
KEYCLOAK_DATABASE_USER: postgres
KEYCLOAK_DATABASE_PASSWORD: postgres
KEYCLOAK_DATABASE_SCHEMA: public
KEYCLOAK_EXTRA_ARGS: "-Dkeycloak.profile.feature.scripts=enabled"
KC_HOSTNAME: postgres
ENV KC_HOSTNAME_STRICT: false
ENV KC_HTTP_ENABLED: true
ports:
- 8080:8080
volumes:
- ./keycloak/export:/tmp/export
- ./rus-theme:/opt/bitnami/keycloak/themes/my-theme
- ./keycloak/configuration/standalone-ha.xml:/bitnami/keycloak/configuration/standalone-ha.xml:ro
command:
- /bin/bash
- -c
- |
/opt/bitnami/keycloak/bin/kc.sh start-dev
depends_on:
- postgres
postgres:
image: postgres:10
container_name: postgres
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
mailhog:
# Conectarse al nombre del container para acceder
# Ejemplo: mailhog:1025
image: mailhog/mailhog
logging:
driver: 'none' # disable saving logs
container_name: mailhog
ports:
- 1025:1025 # smtp server
- 8025:8025 # web ui
volumes:
postgres_data:
driver: local
KEYCLOAK_DATABASE_* properties were used in the old versions of Keycloak (pre-Quarkus).
New properties are defined as KC_DB_* (see https://www.keycloak.org/server/all-config?q=db)
Experimenting with Postgres and Pgadmin4 with Docker Compose. Initially I use this as my docker-compose.yml file.
version: '3.8'
services:
db:
container_name: pg_container
image: postgres
restart: always
volumes:
- ./postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: test_db
ports:
- "5432:5432"
pgadmin:
container_name: pgadmin4_container
image: dpage/pgadmin4
restart: always
volumes:
- ./data/pgadmin:/var/lib/pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: admin#admin.com
PGADMIN_DEFAULT_PASSWORD: root
ports:
- "5050:80"
links:
- "db:psql-server"
I ran:
chown -R 5050:5050 data
So that pgadmin4 could save it's configuration and it worked beautifully. Then I tried to bring it down and update the POSTGRES_PASSWORD to test.
docker-compose down
UPDATED docker-compose.yml file to:
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: test
And then brought it back up:
docker-compose up
To my surprise when connecting to Postgres from Pgadmin4 test does not work as the password, but root does. So my question is when Postgres creates the data directory does it store the credentials somewhere in there? Is there a way to update the password and user once it has been initially created?
I have the following docker-compose file:
version: '3.5'
services:
postgres:
container_name: postgres_container
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /data/postgres
volumes:
- postgres:/data/postgres
onrun:
psql -h=localhost -P=${POSTGRES_PASSWORD} -U=${POSTGRES_USER} -tc "SELECT 1 FROM pg_database WHERE datname = 'premiership'" | grep -q 1 || psql -h=localhost -P=${POSTGRES_PASSWORD}-U=${POSTGRES_USER}c "CREATE DATABASE premiership"
ports:
- "5432:5432"
networks:
- postgres
restart: unless-stopped
The above does not work because there is no onrun in docker-compose services.
All I want to do is create a database if it does not exist but this is insanely difficult because I don't know when the service is up.
Also it is not easy to do this in postgres. I tried mapping a volume so that an initdb.sql is ran:
volumes:
- postgres:/data/postgres
- ./initdb/1_schema.sql:/docker-entrypoint-initdb.d/1_schema.sql
1_schema.sql looks like this:
SELECT datname
FROM pg_database
WHERE datname='premiership'';
IF datname='
premiership'
THEN CREATE DATABASE premiership PASSWORD 'test';
END IF;
THe database is not created and when I run docker-compose logs I don't see anything about running the script.
Have you tried setting POSTGRES_DB variable in your docker-compose.yml environment ?
image: postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
POSTGRES_DB: premiership
PGDATA: /data/postgres
volumes:
see https://hub.docker.com/_/postgres :
POSTGRES_DB
This optional environment variable can be used to define a different
name for the default database that is created when the image is first
started. If it is not specified, then the value of POSTGRES_USER will
be used.
I am trying to run keycloak in docker and to save its data in PostgreSQl.
But nothing is being saved.
this is the docker-compose.yml file:
version: '2'
services:
db:
build: "./Main Database Backup"
environment:
POSTGRES_DB: ${DB_POSTGRES_APP_DATABASE}
POSTGRES_USER: ${DB_POSTGRES_APP_USER}
POSTGRES_PASSWORD: ${DB_POSTGRES_APP_PASSW}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
restart: unless-stopped
keycloak-postgres:
image: postgres:10-alpine
environment:
POSTGRES_DB: ${KEYCLOAK_DATABASE}
POSTGRES_PASSWORD: ${KEYCLOAK_DATABASE_PASSW}
POSTGRES_USER: ${KEYCLOAK_DATABASE_USER}
PGDATA: /var/lib/postgresql/data/pgdata
restart: unless-stopped
keycloak:
build: "./Keycloak Realm Export"
depends_on:
- keycloak-postgres
environment:
KEYCLOAK_USER: ${KEYCLOAK_USER}
KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD}
POSTGRES_USER: ${KEYCLOAK_DATABASE_USER}
POSTGRES_PASSWORD: ${KEYCLOAK_DATABASE_PASSW}
POSTGRES_PORT_5432_TCP_ADDR: keycloak-postgres
ports:
- "8080:8080"
Dockerfile in for keycloak
FROM jboss/keycloak:3.4.3.Final
WORKDIR /opt/jboss/keycloak
COPY realm-export.json initial_data.json
# RUN ./bin/standalone.sh -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=initial_data.json -Dkeycloak.migration.strategy=OVERWRITE_EXISTING
RUN ./bin/add-user-keycloak.sh -r master -u admin -p password
ENTRYPOINT [ "/opt/jboss/docker-entrypoint.sh" ]
CMD ["-b", "0.0.0.0", "-Dkeycloak.import=/opt/jboss/keycloak/initial_data.json"]
That db is the main database which is for my API and its working correctly.
While the keycloak-postgres is the database for keycloak and its not saving any data.
Also I have created a database in that server with the same name as ${KEYCLOAK_DATABASE} and I have created a user and gave all privileges to that server, so it wont be a permission error.
And I have provided all the environment variables correctly.
Also regarding to commented code in keycloak Dockerfile, I'm trying to import a realm which is not working.
When I'm commenting that POSTGRES_PORT_5432_TCP_ADDR in docker-compose.yml its throwing this error:
2018-08-31T08:22:05.251344638Z 08:22:05,250 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
2018-08-31T08:22:05.251375320Z ("subsystem" => "datasources"),
2018-08-31T08:22:05.251383320Z ("data-source" => "KeycloakDS")
2018-08-31T08:22:05.251402169Z ]) - failure description: "WFLYCTL0211: Cannot resolve expression 'jdbc:postgresql://${env.POSTGRES_PORT_5432_TCP_ADDR}:${env.POSTGRES_PORT_5432_TCP_PORT:5432}/${env.POSTGRES_DATABASE:keycloak}'"
This isn't Keycloak related, it's more Docker container related (and postgres). Each time you stop a container you going to loose your data.
What you need to use is Volumes ... meaning. Map a driver on your PC to the docker container. Such that each time the container starts again it uses this drive therefore able to retain data. You need something along the lines of:
version: '2'
volumes:
postgres_data:
driver: local
services:
db:
build: "./Main Database Backup"
environment:
POSTGRES_DB: ${DB_POSTGRES_APP_DATABASE}
POSTGRES_USER: ${DB_POSTGRES_APP_USER}
POSTGRES_PASSWORD: ${DB_POSTGRES_APP_PASSW}
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- postgres_data:/var/lib/postgresql/data
- ./data:/docker-entrypoint-initdb.d
ports:
- "5432:5432"
restart: unless-stopped