From 2fbe9ad343e82679ba0573a7daa510cfbe488ddf Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 19 Sep 2024 19:33:12 +0200 Subject: Docker dev and prod separation --- .env.example | 2 ++ Dockerfile | 6 ++++-- compose.dev.yml | 18 ++++++++++++++++++ compose.yml | 20 ++++---------------- 4 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 compose.dev.yml diff --git a/.env.example b/.env.example index 7682611..af9a15b 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,8 @@ POSTGRES_PASSWORD=postgres MAILER_DSN= MAILER_FROM= PUBLIC_URL= +PGADMIN_EMAIL= +PGADMIN_PASSWORD= #MYSTIC_FORUM_THEME=default #REGISTRATION_ENABLED=1 #MYSTIC_FORUM_TITLE= diff --git a/Dockerfile b/Dockerfile index abd5d04..ccbf6e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,10 @@ RUN docker-php-ext-configure gd \ RUN docker-php-ext-install gd zip pgsql intl RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -FROM base +FROM base AS dev COPY ./000-default.conf /etc/apache2/sites-available/000-default.conf -COPY ./src /var/www/html WORKDIR /var/www/html + +FROM dev AS prod +COPY ./src /var/www/html RUN composer install diff --git a/compose.dev.yml b/compose.dev.yml new file mode 100644 index 0000000..4028ddc --- /dev/null +++ b/compose.dev.yml @@ -0,0 +1,18 @@ +services: + app: + build: + context: ./ + target: dev + restart: unless-stopped + volumes: + - "./src/:/var/www/html/:ro" + admin: + image: dpage/pgadmin4:latest + restart: unless-stopped + depends_on: + - db + ports: + - 127.0.0.1:8314:80 + environment: + PGADMIN_DEFAULT_EMAIL: '${PGADMIN_EMAIL}' + PGADMIN_DEFAULT_PASSWORD: '${PGADMIN_PASSWORD}' diff --git a/compose.yml b/compose.yml index 78349a1..7b68e2e 100644 --- a/compose.yml +++ b/compose.yml @@ -1,29 +1,17 @@ services: app: - build: . + build: + context: ./ + target: prod restart: unless-stopped env_file: ./.env depends_on: - db ports: - - 8313:80 - # volumes: - # - "./src/:/var/www/html/:ro" + - 127.0.0.1:8313:80 db: image: postgres restart: unless-stopped env_file: ./.env - # ports: - # - 5432:5432 volumes: - ./data/db:/var/lib/postgresql/data - # admin: - # image: dpage/pgadmin4:latest - # restart: unless-stopped - # depends_on: - # - db - # ports: - # - 8314:80 - # environment: - # PGADMIN_DEFAULT_EMAIL: 'pgadmin@jonaskohl.de' - # PGADMIN_DEFAULT_PASSWORD: 'admin' -- cgit v1.2.3