Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Add postgres docker compose setup #6759

Merged
merged 23 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b3cd6a6
streamline mysql and postgresl docker network settings
4ludwig4 Jun 19, 2023
7c89e85
streamline postgresql naming to postgres in docker compose
4ludwig4 Jun 22, 2023
a018b65
created dev.env with all development configurations for artemis
4ludwig4 Jun 22, 2023
d54abf6
refactored and added documentation to .env files
4ludwig4 Jun 22, 2023
9976e8e
added postgres setups
4ludwig4 Jun 23, 2023
e7e72c5
add postgres setups in docs with file permission tips for admins
4ludwig4 Jun 23, 2023
fc57de6
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Jun 23, 2023
5f5e94c
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Jun 28, 2023
9eb9c3a
add clear registry urls for postgres and also mailhog
4ludwig4 Jun 30, 2023
ce2e4b1
Merge remote-tracking branch 'origin/develop' into feature/docker/pos…
4ludwig4 Jun 30, 2023
475489f
Merge remote-tracking branch 'origin/develop' into feature/docker/pos…
4ludwig4 Jul 12, 2023
fd022cf
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Jul 13, 2023
b9b7046
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Jul 20, 2023
5191c8d
Merge remote-tracking branch 'origin/develop' into feature/docker/pos…
4ludwig4 Aug 18, 2023
b534ede
fix merge conflicts and adopt postgres cypress settings
4ludwig4 Aug 18, 2023
b2ad4e0
fix missing postgres data volume renaming
4ludwig4 Aug 18, 2023
1f22b34
Merge remote-tracking branch 'origin/develop' into feature/docker/pos…
4ludwig4 Aug 28, 2023
579778a
Merge remote-tracking branch 'origin/develop' into feature/docker/pos…
4ludwig4 Aug 31, 2023
e50d6f0
Update .bamboo/E2E-tests/execute.sh
4ludwig4 Sep 2, 2023
6cde804
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Sep 2, 2023
6179f77
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Sep 10, 2023
16d14ee
Update dev.env
4ludwig4 Sep 10, 2023
ea696f1
Merge branch 'develop' into feature/docker/postgresql-setups
4ludwig4 Sep 12, 2023
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
2 changes: 1 addition & 1 deletion .bamboo/E2E-tests/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker container rm $(docker ps -a -q) || true
docker volume rm $(docker volume ls -q) || true

docker compose -f ./docker/cypress-E2E-tests-mysql.yml down -v
docker compose -f ./docker/cypress-E2E-tests-postgresql.yml down -v
docker compose -f ./docker/cypress-E2E-tests-postgres.yml down -v

# show all running docker containers and volumes after the cleanup to detect issues
echo "SHOW RUNNING Docker containers and volumes:"
Expand Down
6 changes: 3 additions & 3 deletions .bamboo/E2E-tests/execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ DB=$1

if [ "$DB" = "mysql" ]; then
COMPOSE_FILE="cypress-E2E-tests-mysql.yml"
elif [ "$DB" = "postgresql" ]; then
COMPOSE_FILE="cypress-E2E-tests-postgresql.yml"
elif [ "$DB" = "postgres" ]; then
COMPOSE_FILE="cypress-E2E-tests-postgres.yml"
else
echo "Invalid database type. Please choose either mysql or postgresql."
echo "Invalid database type. Please choose either mysql or postgres."
4ludwig4 marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ data-exports/
!/docker/.docker-data/artemis-data/.gitkeep
/docker/.docker-data/artemis-mysql-data/*
!/docker/.docker-data/artemis-mysql-data/.gitkeep
/docker/.docker-data/artemis-postgres-data/*
!/docker/.docker-data/artemis-postgres-data/.gitkeep

######################
# Cypress
Expand Down
Empty file.
7 changes: 2 additions & 5 deletions docker/artemis-dev-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ services:
# expose the port to make it reachable docker internally even if the external port mapping changes
expose:
- "5005"
environment:
# The following enables the Java Remote Debugging port. More infos in the documentation:
# https://docs.artemis.cit.tum.de/dev/setup.html#debugging-with-docker
_JAVA_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
SPRING_PROFILES_ACTIVE: artemis,scheduling,athene,dev,docker
env_file:
- ./artemis/config/dev.env
depends_on:
mysql:
condition: service_healthy
Expand Down
39 changes: 39 additions & 0 deletions docker/artemis-dev-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis-Dev-Postgres Setup
# ----------------------------------------------------------------------------------------------------------------------

services:
artemis-app:
extends:
file: ./artemis.yml
service: artemis-app
# just add this linux workaround for docker compose in a development version of artemis as developers
# might want to access external services on the docker host
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8080:8080"
- "5005:5005" # Java Remote Debugging port declared in the java cmd options
# expose the port to make it reachable docker internally even if the external port mapping changes
expose:
- "5005"
env_file:
- ./artemis/config/dev.env
- ./artemis/config/postgres.env
depends_on:
postgres:
condition: service_healthy
postgres:
extends:
file: ./postgres.yml
service: postgres

networks:
artemis:
driver: "bridge"
name: artemis
volumes:
artemis-postgres-data:
name: artemis-postgres-data
artemis-data:
name: artemis-data
38 changes: 38 additions & 0 deletions docker/artemis-prod-postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis-Prod-Postgres Setup
# ----------------------------------------------------------------------------------------------------------------------

services:
artemis-app:
extends:
file: ./artemis.yml
service: artemis-app
depends_on:
postgres:
condition: service_healthy
restart: on-failure:3
volumes:
- ./.docker-data/artemis-data:/opt/artemis/data
env_file:
- ./artemis/config/postgres.env
postgres:
extends:
file: ./postgres.yml
service: postgres
restart: on-failure:3
volumes:
- ./.docker-data/artemis-postgres-data:/var/lib/postgresql/data
nginx:
extends:
file: ./nginx.yml
service: nginx
# the artemis-app service needs to be started, otherwise there are problems with name resolution in docker
depends_on:
artemis-app:
condition: service_started
restart: on-failure:3

networks:
artemis:
driver: "bridge"
name: artemis
6 changes: 0 additions & 6 deletions docker/artemis/config/cypress-postgres.env

This file was deleted.

4 changes: 4 additions & 0 deletions docker/artemis/config/cypress.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis configurations for the Cypress E2E setups
# ----------------------------------------------------------------------------------------------------------------------

SPRING_PROFILES_ACTIVE="artemis,scheduling,bamboo,bitbucket,jira,prod,docker"

SPRING_DATASOURCE_USERNAME="root"
Expand Down
11 changes: 11 additions & 0 deletions docker/artemis/config/dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis configurations for Dev Artemis setups
# ----------------------------------------------------------------------------------------------------------------------
# The default Artemis Spring profiles for Docker are defined here.
# ----------------------------------------------------------------------------------------------------------------------

SPRING_PROFILES_ACTIVE: artemis,scheduling,athene,dev,docker

# The following enables the Java Remote Debugging port. More infos in the documentation:
# https://docs.artemis.cit.tum.de/dev/setup.html#debugging-with-docker
_JAVA_OPTIONS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
9 changes: 9 additions & 0 deletions docker/artemis/config/postgres.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis configurations for Postgres setups
# ----------------------------------------------------------------------------------------------------------------------

SPRING_DATASOURCE_URL="jdbc:postgresql://artemis-postgres:5432/Artemis?sslmode=disable"
SPRING_DATASOURCE_USERNAME="postgres"

SPRING_JPA_DATABASE_PLATFORM="org.hibernate.dialect.PostgreSQL10Dialect"
SPRING_JPA_DATABASE="POSTGRESQL"
16 changes: 15 additions & 1 deletion docker/artemis/config/prod-application-local.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# ----------------------------------------------------------------------------------------------------------------------
# Artemis configurations for Prod Artemis setups
# ----------------------------------------------------------------------------------------------------------------------
# The default Artemis Spring profiles for Docker are defined here.
# ----------------------------------------------------------------------------------------------------------------------

SPRING_PROFILES_ACTIVE: artemis,scheduling,athene,prod,docker

# ----------------------------------------------------------------------------------------------------------------------
# Secret Overrides
# ----------------------------------------------------------------------------------------------------------------------
# Change these default secrets in another not-commited environment override file for prod systems!
# ----------------------------------------------------------------------------------------------------------------------
ARTEMIS_ATHENE_BASE64SECRET="YWVuaXF1YWRpNWNlaXJpNmFlbTZkb283dXphaVF1b29oM3J1MWNoYWlyNHRoZWUzb2huZ2FpM211bGVlM0VpcAo="
ARTEMIS_USERMANAGEMENT_INTERNALADMIN_USERNAME="artemis_admin"
ARTEMIS_USERMANAGEMENT_INTERNALADMIN_PASSWORD="artemis_admin"
Expand All @@ -17,6 +27,10 @@ SPRING_WEBSOCKET_BROKER_PASSWORD="guest"
JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64SECRET="bXktc2VjcmV0LWtleS13aGljaC1zaG91bGQtYmUtY2hhbmdlZC1pbi1wcm9kdWN0aW9uLWFuZC1iZS1iYXNlNjQtZW5jb2RlZAo="
JHIPSTER_REGISTRY_PASSWORD="AN-ADMIN-PASSWORD-THAT-MUST-BE-CHANGED (FROM REGISTRY CONFIG)"


# ----------------------------------------------------------------------------------------------------------------------
# Plain Prod Artemis Overrides
# ----------------------------------------------------------------------------------------------------------------------
# Keep these at a minimum! Try to change the default values either in the application-docker.yml or even better
# in one of the other application.yml or application-*.yml files.
# ----------------------------------------------------------------------------------------------------------------------
ARTEMIS_USERMANAGEMENT_USEEXTERNAL="false"
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# ----------------------------------------------------------------------------------------------------------------------
# Cypress Setup PostgreSQL
# Cypress Setup Postgres
# ----------------------------------------------------------------------------------------------------------------------

services:
postgresql:
postgres:
extends:
file: ./postgresql.yml
service: postgresql
file: ./postgres.yml
service: postgres

artemis-app:
extends:
file: ./artemis.yml
service: artemis-app
depends_on:
postgresql:
postgres:
condition: service_healthy
env_file:
- ./artemis/config/cypress.env
- ./artemis/config/cypress-postgres.env
- ./artemis/config/postgres.env

nginx:
extends:
Expand Down Expand Up @@ -48,7 +48,7 @@ networks:
driver: "bridge"
name: artemis
volumes:
artemis-postgresql-data:
name: artemis-postgresql-data
artemis-postgres-data:
name: artemis-postgres-data
artemis-data:
name: artemis-data
17 changes: 10 additions & 7 deletions docker/postgresql.yml → docker/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
# ----------------------------------------------------------------------------------------------------------------------

services:
postgresql:
container_name: artemis-postgresql
postgres:
container_name: artemis-postgres
image: postgres:15.3-alpine
pull_policy: always
user: postgres
command: ["postgres", "-c", "max_connections=200"]
volumes:
- artemis-postgresql-data:/var/lib/postgresql/data
- artemis-postgres-data:/var/lib/postgresql/data
# DO NOT use this default file for production systems!
env_file:
- ./postgresql/default.env
- ./postgres/default.env
ports:
- "5432:5432"
- "127.0.0.1:5432:5432"
# expose the port to make it reachable docker internally even if the external port mapping changes
expose:
- "5432"
healthcheck:
test: pg_isready -U postgres -d Artemis
interval: 5s
Expand All @@ -32,5 +35,5 @@ networks:
name: artemis

volumes:
artemis-postgresql-data:
name: artemis-postgresql-data
artemis-postgres-data:
name: artemis-postgres-data
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
POSTGRES_HOST_AUTH_METHOD=trust
POSTGRES_USER=postgres
POSTGRES_DB=Artemis
PGDATA=/var/lib/postgresql/data/pgdata
14 changes: 7 additions & 7 deletions docker/test-server-postgresql.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ----------------------------------------------------------------------------------------------------------------------
# Setup for a test server with PostgreSQL
# Setup for a test server with Postgres
# ----------------------------------------------------------------------------------------------------------------------
# It is designed to take in a lot of environment variables to take in all the configuration of the test server.
# ----------------------------------------------------------------------------------------------------------------------
Expand All @@ -11,7 +11,7 @@ services:
service: artemis-app
image: ghcr.io/ls1intum/artemis:${ARTEMIS_DOCKER_TAG:-latest}
depends_on:
postgresql:
postgres:
condition: service_healthy
pull_policy: always
restart: always
Expand All @@ -22,15 +22,15 @@ services:
- ${ARTEMIS_LEGAL_MOUNT:-./.docker-data/artemis-legal}:/opt/artemis/legal
- ${ARTEMIS_DATA_EXPORT_MOUNT:-./.docker-data/artemis-data-exports}:/opt/artemis/data-exports

postgresql:
postgres:
extends:
file: ./postgresql.yml
service: postgresql
file: ./postgres.yml
service: postgres
restart: always
env_file:
- ${DATABASE_ENV_FILE:-./postgresql/default.env}
- ${DATABASE_ENV_FILE:-./postgres/default.env}
volumes:
- ${DATABASE_VOLUME_MOUNT:-./.docker-data/artemis-postgresql-data}:/var/lib/postgresql/data
- ${DATABASE_VOLUME_MOUNT:-./.docker-data/artemis-postgres-data}:/var/lib/postgresql/data

nginx:
extends:
Expand Down
21 changes: 21 additions & 0 deletions docs/admin/productionSetupTips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ Place the webpage that should be shown in case of Artemis being unreachable (in

error_page 501 502 503 /service_down.html;
}

## Gather all Docker Compose-related tips here which are not relevant for developers!
.. _docker_compose_setup_prod:

Docker Compose Setup
--------------------

The :ref:`development section of the documentation <docker_compose_setup_dev>` provides a introduction to
Docker Compose setups for Artemis.
This section provides additional information for administrators.

File Permissions
^^^^^^^^^^^^^^^^
If you use the production Docker Compose Setups (``artemis-prod-*.yml``) with bind mounts change
the file permissions accordingly:

.. code:: bash

sudo chown -R $(id -u):70 docker/.docker-data/artemis-postgres-data
sudo chown -R $(id -u):999 docker/.docker-data/artemis-mysql-data
sudo chown -R $(id -u):1337 docker/.docker-data/artemis-data
16 changes: 12 additions & 4 deletions docs/dev/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ PostgreSQL Setup

No special PostgreSQL settings are required.
You can either use your package manager’s version, or set it up using a container.
An example Docker Compose setup based on the `official container image <https://hub.docker.com/_/postgres>`_ is provided in ``src/main/docker/postgresql.yml``.
An example Docker Compose setup based on the `official container image <https://hub.docker.com/_/postgres>`_
is provided in ``src/main/docker/postgres.yml``.

When setting up the Artemis server, the following values need to be added/updated in the server configuration (see setup steps below) to connect to PostgreSQL instead of MySQL:

Expand Down Expand Up @@ -670,6 +671,8 @@ HTTP. We need to extend the configuration in the file

------------------------------------------------------------------------------------------------------------------------

.. _docker_compose_setup_dev:

Alternative: Docker Compose Setup
---------------------------------

Expand Down Expand Up @@ -716,7 +719,11 @@ The easiest way to configure a local deployment via Docker is a deployment with
In the directory ``docker/`` you can find the following *docker compose* files for different **setups**:

* ``artemis-dev-mysql.yml``: **Artemis-Dev-MySQL** Setup containing the development build of Artemis and a MySQL DB
* ``artemis-dev-postgres.yml``: **Artemis-Dev-Postgres** Setup containing the development build of Artemis and
a PostgreSQL DB
* ``artemis-prod-mysql.yml``: **Artemis-Prod-MySQL** Setup containing the production build of Artemis and a MySQL DB
* ``artemis-prod-postgres.yml``: **Artemis-Prod-Postgres** Setup containing the production build of Artemis and
a PostgreSQL DB
* ``atlassian.yml``: **Atlassian** Setup containing a Jira, Bitbucket and Bamboo instance
(see `Bamboo, Bitbucket and Jira Setup Guide <#bamboo-bitbucket-and-jira-setup>`__
for the configuration of this setup)
Expand All @@ -726,14 +733,15 @@ In the directory ``docker/`` you can find the following *docker compose* files f
* ``monitoring.yml``: **Prometheus-Grafana** Setup containing a Prometheus and Grafana instance
* ``mysql.yml``: **MySQL** Setup containing a MySQL DB instance
* ``nginx.yml``: **Nginx** Setup containing a preconfigured Nginx instance
* ``postgresql.yml``: **PostgreSQL** Setup containing a PostgreSQL DB instance
* ``postgres.yml``: **Postgres** Setup containing a PostgreSQL DB instance

Two example commands to run such setups:
Three example commands to run such setups:

.. code:: bash

docker compose -f docker/atlassian.yml up
docker compose -f docker/mysql.yml -f docker/gitlab-jenkins.yml up
docker compose -f docker/artemis-dev-postgres.yml up

.. tip::
There is also a single ``docker-compose.yml`` in the directory ``docker/`` which mirrors the setup of ``artemis-prod-mysql.yml``.
Expand All @@ -747,7 +755,7 @@ is defined in the following files:
* ``artemis.yml``: **Artemis Service**
* ``mysql.yml``: **MySQL DB Service**
* ``nginx.yml``: **Nginx Service**
* ``postgresql.yml``: **PostgreSQL DB Service**
* ``postgres.yml``: **PostgreSQL DB Service**
* ``gitlab.yml``: **GitLab Service**
* ``jenkins.yml``: **Jenkins Service**

Expand Down