Skip to content

Commit

Permalink
Updated docker compose configuration not to use configs but volumes t…
Browse files Browse the repository at this point in the history
…o not require swarm mode
  • Loading branch information
oskardudycz committed Jun 20, 2024
1 parent a3750bf commit 3d42e35
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 57 deletions.
21 changes: 16 additions & 5 deletions PostgresOutboxPattern.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{CD59A1
docker-compose.yml = docker-compose.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{9F497531-24EF-4744-B06C-B766562A9852}"
ProjectSection(SolutionItems) = preProject
sql\init.sql = sql\init.sql
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PostgresOutbox", "src\PostgresOutbox\PostgresOutbox.csproj", "{E1AD98FC-42B1-4B7B-AF44-8057B7A61FDD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{D0AB0FF4-C8A1-4B4B-A682-64F353A2D248}"
ProjectSection(SolutionItems) = preProject
src\Directory.Build.props = src\Directory.Build.props
.github\workflows\build.dotnet.yml = .github\workflows\build.dotnet.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{47B6EDAC-2EBC-4368-BAD6-2B8695E7D067}"
Expand All @@ -32,6 +28,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Commons", "src\Commons\Comm
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "src\Tests\Tests.csproj", "{2BBDA071-FB1C-4D62-A954-B22EA6B1C738}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "pgAdmin", "pgAdmin", "{C050E9E8-3FB6-4581-953F-31826E385FB4}"
ProjectSection(SolutionItems) = preProject
docker\pgAdmin\servers.json = docker\pgAdmin\servers.json
docker\pgAdmin\pgpass = docker\pgAdmin\pgpass
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "postgres", "postgres", "{8AAAA344-B5FD-48D9-B2BA-379E374448D4}"
ProjectSection(SolutionItems) = preProject
docker\postgres\init.sql = docker\postgres\init.sql
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -65,4 +72,8 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9A868C51-0460-4700-AF33-E1A921192614}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C050E9E8-3FB6-4581-953F-31826E385FB4} = {CD59A1A0-F40D-4047-87A3-66C0F1519FA5}
{8AAAA344-B5FD-48D9-B2BA-379E374448D4} = {CD59A1A0-F40D-4047-87A3-66C0F1519FA5}
EndGlobalSection
EndGlobal
89 changes: 37 additions & 52 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,39 @@
version: '3.8' # Specify Docker Compose version

services:
postgres:
image: postgres:15.1-alpine
ports:
- "5432:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
command:
- "postgres"
- "-c"
- "wal_level=logical"
- "-c"
- "wal_compression=on"
volumes:
- ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql

pgadmin: #http://localhost:5050
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-postgres}
- PGADMIN_CONFIG_SERVER_MODE=False
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
ports:
- "${PGADMIN_PORT:-5050}:80"
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
user: root
configs:
- source: servers.json
target: /pgadmin4/servers.json
- source: pgpass
target: /pgpass
depends_on:
- postgres
restart: unless-stopped
postgres:
image: postgres:15.1-alpine
ports:
- "5432:5432"
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
command:
- "postgres"
- "-c"
- "wal_level=logical"
- "-c"
- "wal_compression=on"
volumes:
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql

pgadmin:
container_name: pgadmin_container
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-postgres}
- PGADMIN_CONFIG_SERVER_MODE=False
- PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
ports:
- "${PGADMIN_PORT:-5050}:80"
entrypoint: /bin/sh -c "chmod 600 /pgpass; /entrypoint.sh;"
user: root
volumes:
- ./docker/pgAdmin/pgpass:/pgpass
- ./docker/pgAdmin/servers.json:/pgadmin4/servers.json
depends_on:
- postgres
restart: unless-stopped

configs:
pgpass:
content: postgres:5432:*:postgres:postgres
servers.json:
content: |
{"Servers": {"1": {
"Group": "Servers",
"Name": "docker_postgres",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "postgres",
"PassFile": "/pgpass",
"SSLMode": "prefer"
}}}
1 change: 1 addition & 0 deletions docker/pgAdmin/pgpass
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
postgres:5432:*:postgres:postgres
14 changes: 14 additions & 0 deletions docker/pgAdmin/servers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Servers": {
"1": {
"Group": "Servers",
"Name": "docker_postgres",
"Host": "postgres",
"Port": 5432,
"MaintenanceDB": "postgres",
"Username": "postgres",
"PassFile": "/pgpass",
"SSLMode": "prefer"
}
}
}
File renamed without changes.

0 comments on commit 3d42e35

Please sign in to comment.