Docker update variables

This commit is contained in:
Ernest Wiśniewski 2023-06-08 12:01:21 +02:00
parent 81a40ded39
commit abe497c279
5 changed files with 21 additions and 17 deletions

View file

@ -14,8 +14,9 @@
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
# kbin variables
SERVER_NAME=app.localhost
KBIN_DOMAIN=app.localhost
#SERVER_NAME="instance-domain.com" # production
SERVER_NAME="kbin.localhost, caddy:80"
KBIN_DOMAIN=kbin.localhost
KBIN_TITLE=/kbin
KBIN_DEFAULT_LANG=en
KBIN_FEDERATION_ENABLED=true
@ -62,7 +63,7 @@ APP_SECRET=427f5e2940e5b2472c1b44b2d06e0525
POSTGRES_DB=kbin
POSTGRES_USER=kbin
POSTGRES_PASSWORD=!ChangeThisPostgresPass!
POSTGRES_VERSION=14
POSTGRES_VERSION=13
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@127.0.0.1:5432/${POSTGRES_DB}?serverVersion=${POSTGRES_VERSION}&charset=utf8"
###< doctrine/doctrine-bundle ###
@ -97,7 +98,7 @@ CADDY_MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
###< symfony/mercure-bundle ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(app.localhost|127\.0\.0\.1)(:[0-9]+)?$'
CORS_ALLOW_ORIGIN='^https?://(kbin.localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###
###> symfony/lock ###

View file

@ -19,6 +19,7 @@ services:
- host.docker.internal:host-gateway
caddy:
command: ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile", "--watch"]
volumes:
- ./public:/srv/app/public:ro
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro

View file

@ -19,10 +19,10 @@ services:
start_period: 30s
environment:
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-14}&charset=${POSTGRES_CHARSET:-utf8}
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-13}&charset=${POSTGRES_CHARSET:-utf8}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-app.localhost}/.well-known/mercure
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-kbin.localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
REDIS_HOST: redis
REDIS_PORT: 6379
@ -40,11 +40,10 @@ services:
depends_on:
- php
environment:
SERVER_NAME: ${SERVER_NAME:-app.localhost, caddy:80}
SERVER_NAME: ${SERVER_NAME:-kbin.localhost, caddy:80}
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
restart: unless-stopped
command: [ "caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile", "--watch" ]
volumes:
- php_socket:/var/run/php
- caddy_data:/data
@ -91,9 +90,9 @@ services:
target: symfony_messenger
command: 'sh -c "php bin/console messenger:consume async --time-limit=3600"'
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-14}&charset=${POSTGRES_CHARSET:-utf8}
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-13}&charset=${POSTGRES_CHARSET:-utf8}
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-app.localhost}/.well-known/mercure
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-kbin.localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
REDIS_HOST: redis
REDIS_PORT: 6379
@ -108,7 +107,7 @@ services:
timeout: 3s
retries: 3
start_period: 30s
restart: always
restart: unless-stopped
depends_on:
- php
@ -119,9 +118,9 @@ services:
target: symfony_messenger
command: 'sh -c "php bin/console messenger:consume async_ap --time-limit=3600"'
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-14}&charset=${POSTGRES_CHARSET:-utf8}
DATABASE_URL: postgresql://${POSTGRES_USER:-kbin}:${POSTGRES_PASSWORD:-ChangeMe}@database:5432/${POSTGRES_DB:-kbin}?serverVersion=${POSTGRES_VERSION:-13}&charset=${POSTGRES_CHARSET:-utf8}
MERCURE_URL: ${CADDY_MERCURE_URL:-http://caddy/.well-known/mercure}
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-app.localhost}/.well-known/mercure
MERCURE_PUBLIC_URL: https://${SERVER_NAME:-kbin.localhost}/.well-known/mercure
MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
REDIS_HOST: redis
REDIS_PORT: 6379
@ -136,7 +135,7 @@ services:
timeout: 3s
retries: 3
start_period: 30s
restart: always
restart: unless-stopped
depends_on:
- php
- rabbitmq

View file

@ -165,7 +165,7 @@ $ yarn build
$ docker compose down && docker compose up
```
Open [https://app.localhost](https://app.localhost) in your favorite web browser and accept the auto-generated TLS certificate
Open [https://kbin.localhost](https://kbin.localhost) in your favorite web browser and accept the auto-generated TLS certificate
#### Production
@ -212,7 +212,7 @@ $ docker exec -it container_id pg_dump -U kbin kbin > dump.sql
$ docker compose exec -T database psql -U kbin kbin < dump.sql
```
#### S3 Images storage
#### S3 Images storage (optional)
.env

View file

@ -28,7 +28,10 @@
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
<script type="application/json" id="mercure-url">{{ mercure()|raw }}</script>
{# <script type="application/json" id="mercure-url">{{ mercure()|raw }}</script>#}
<script type="application/json" id="mercure-url">
{{- 'https://' ~ kbin_domain() ~ '/.well-known/mercure' }}
</script>
<script>
window.KBIN_USER = "{{ app.user ? app.user.username : null }}";
window.KBIN_MAGAZINE = "{{ magazine is defined and magazine ? magazine.name : null }}"