Skip to content

Commit 3c57948

Browse files
committed
Add postgres
1 parent 9b36d9c commit 3c57948

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ WORKDIR /var/www/html
1010
RUN apt-get update \
1111
&& apt-get install -y --no-install-recommends \
1212
git unzip libzip-dev libicu-dev libpng-dev libonig-dev libxml2-dev \
13-
libc-client2007e-dev libkrb5-dev libssl-dev \
13+
libc-client2007e-dev libkrb5-dev libssl-dev libpq-dev \
1414
&& docker-php-ext-configure intl \
1515
&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \
1616
&& docker-php-ext-install -j"$(nproc)" \
17-
pdo pdo_mysql zip intl imap \
17+
pdo pdo_mysql pdo_pgsql zip intl imap \
1818
&& rm -rf /var/lib/apt/lists/*
1919

2020
# Enable Apache modules and set DocumentRoot to /public

docker-compose.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42
app:
53
build: .
@@ -9,24 +7,30 @@ services:
97
- "8081:80"
108
environment:
119
# Database connection (mirrors config/parameters.yml expectations)
12-
PHPLIST_DATABASE_DRIVER: pdo_mysql
13-
PHPLIST_DATABASE_HOST: db
14-
PHPLIST_DATABASE_PORT: 3306
10+
# PHPLIST_DATABASE_DRIVER: pdo_mysql
11+
# PHPLIST_DATABASE_HOST: db
12+
# PHPLIST_DATABASE_PORT: 3306
1513
PHPLIST_DATABASE_NAME: phplistdb
1614
PHPLIST_DATABASE_USER: phplist
1715
PHPLIST_DATABASE_PASSWORD: phplist
16+
# To use PostgreSQL instead, override these (e.g. with `-e` or a compose override file):
17+
PHPLIST_DATABASE_DRIVER: pdo_pgsql
18+
PHPLIST_DATABASE_HOST: postgres
19+
PHPLIST_DATABASE_PORT: 5432
1820
# Symfony environment
1921
APP_ENV: prod
2022
APP_DEBUG: "0"
2123
depends_on:
2224
- db
25+
networks: [ appnet ]
26+
2327
# Uncomment to persist logs/cache outside container
2428
# volumes:
2529
# - ./var:/var/www/html/var
2630

2731
db:
2832
image: mysql:8.0
29-
container_name: base-distribution-db
33+
container_name: base-distribution-mysql
3034
environment:
3135
MYSQL_DATABASE: phplistdb
3236
MYSQL_USER: phplist
@@ -40,6 +44,29 @@ services:
4044
interval: 10s
4145
timeout: 5s
4246
retries: 10
47+
networks: [appnet]
48+
49+
postgres:
50+
image: postgres:15
51+
container_name: base-distribution-postgres
52+
environment:
53+
POSTGRES_DB: phplistdb
54+
POSTGRES_USER: phplist
55+
POSTGRES_PASSWORD: phplist
56+
volumes:
57+
- pg_data:/var/lib/postgresql/data
58+
healthcheck:
59+
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB || exit 1"]
60+
interval: 10s
61+
timeout: 5s
62+
retries: 10
63+
networks: [ appnet ]
64+
# command to import data from mysql to postgres
65+
# docker run --rm --network base-distribution_appnet dimitri/pgloader:latest pgloader mysql://phplist:phplist@base-distribution-mysql:3306/phplistdb postgresql://phplist:phplist@base-distribution-postgres:5432/phplistdb
4366

4467
volumes:
4568
db_data:
69+
pg_data:
70+
71+
networks:
72+
appnet:

0 commit comments

Comments
 (0)