diff --git a/api/Dockerfile b/api/Dockerfile index 74b802beb7..1566cfdbb8 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -2,6 +2,17 @@ # Adapted from https://github.com/dunglas/symfony-docker +FROM node as frontend_build + +# user: "node" +WORKDIR /app-src +# environment: +# - NODE_ENV=production +COPY --link ./mapas/src /app-src + +RUN npm i -g pnpm +RUN pnpm i +RUN pnpm run dev # Versions FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream @@ -17,6 +28,9 @@ FROM frankenphp_upstream AS frankenphp_base WORKDIR /app +COPY --link . /app +COPY --link --from=frontend_build /app-src /app/src + # persistent / runtime deps # hadolint ignore=DL3008 RUN apt-get update && apt-get install --no-install-recommends -y \ diff --git a/compose.yaml b/compose.yaml index d37a05607e..24a997b107 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,111 +1,90 @@ services: php: image: redemapas/mapas-api - env_file: - - api/.env depends_on: - database restart: unless-stopped environment: - PWA_UPSTREAM: pwa:3000 - SERVER_NAME: ${SERVER_NAME:-localhost}, php:80 - MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} - MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} - TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} - TRUSTED_HOSTS: ${TRUSTED_HOSTS:-^${SERVER_NAME:-example\.com|localhost}|php$$} - DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-16}&charset=${POSTGRES_CHARSET:-utf8} - MERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure} - MERCURE_PUBLIC_URL: ${CADDY_MERCURE_PUBLIC_URL:-https://${SERVER_NAME:-localhost}/.well-known/mercure} - MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!} - BUILD_ASSETS: 0 - PENDING_PCACHE_RECREATION_INTERVAL: 5 - JOBS_INTERVAL: 5 - # REDIS_CACHE: redis - MAILER_TRANSPORT: smtp://mailhog:1025 - MAILER_FROM: sysadmin@localhost - NUM_PROCESSES: 1 - MC_UPDATES_PROCESSES: 1 - GOOGLE_RECAPTCHA_SITEKEY: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI - GOOGLE_RECAPTCHA_SECRET: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe - # SESSIONS_SAVE_PATH: tcp://sessions:6379 + PWA_UPSTREAM: ${PWA_UPSTREAM} + SERVER_NAME: ${SERVER_NAME} + MERCURE_PUBLISHER_JWT_KEY: ${MERCURE_PUBLISHER_JWT_KEY} + MERCURE_SUBSCRIBER_JWT_KEY: ${MERCURE_SUBSCRIBER_JWT_KEY} + TRUSTED_PROXIES: ${TRUSTED_PROXIES} + TRUSTED_HOSTS: ${TRUSTED_HOSTS} + DATABASE_URL: ${DATABASE_URL} + MERCURE_URL: ${MERCURE_URL} + MERCURE_PUBLIC_URL: ${MERCURE_PUBLIC_URL} + MERCURE_JWT_SECRET: ${MERCURE_JWT_SECRET} + BUILD_ASSETS: ${BUILD_ASSETS} + PENDING_PCACHE_RECREATION_INTERVAL: ${PENDING_PCACHE_RECREATION_INTERVAL} + JOBS_INTERVAL: ${JOBS_INTERVAL} + REDIS_CACHE: ${REDIS_CACHE} + MAILER_TRANSPORT: ${MAILER_TRANSPORT} + MAILER_FROM: ${MAILER_FROM} + NUM_PROCESSES: ${NUM_PROCESSES} + MC_UPDATES_PROCESSES: ${MC_UPDATES_PROCESSES} + GOOGLE_RECAPTCHA_SITEKEY: ${GOOGLE_RECAPTCHA_SITEKEY} + GOOGLE_RECAPTCHA_SECRET: ${GOOGLE_RECAPTCHA_SECRET} + SESSIONS_SAVE_PATH: ${SESSIONS_SAVE_PATH} + build: + context: ./api + target: frankenphp_dev volumes: - - caddy_data:/data - - caddy_config:/config - - var-files:/app/var - ports: - # HTTP - - target: 80 - published: ${HTTP_PORT:-80} - protocol: tcp - # HTTPS - - target: 443 - published: ${HTTPS_PORT:-443} - protocol: tcp - # HTTP/3 - - target: 443 - published: ${HTTP3_PORT:-443} - protocol: udp - - recreate-pending-pcache: - # <<: *base-override - command: sh ./mapas/docker/recreate-pending-pcache-cron.sh - depends_on: - - php - extends: php - ports: !override - - "8443:443" - volumes: - - ./api:/app + # - ./api:/app + # - /app/var - var-files:/app/var # - ./api/frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro # - ./api/frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro + - caddy_data:/data + - caddy_config:/config + # ports: + # # HTTP + # - target: 80 + # published: ${HTTP_PORT:-80} + # protocol: tcp + # # HTTPS + # - target: 443 + # published: ${HTTPS_PORT:-443} + # protocol: tcp + # # HTTP/3 + # - target: 443 + # published: ${HTTP3_PORT:-443} + # protocol: udp + + # recreate-pending-pcache: + # # <<: *base-override + # command: sh ./mapas/docker/recreate-pending-pcache-cron.sh + # depends_on: + # - php + # extends: php + # ports: !override + # - "8443:443" + # volumes: + # - ./api:/app + # - var-files:/app/var + # # - ./api/frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro + # # - ./api/frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro execute-job: - # <<: *base-override extends: service: php - # extends: php command: sh ./mapas/docker/jobs-cron.sh depends_on: - php - ports: !override - - "8444:443" volumes: - - ./api:/app + # - ./api:/app - var-files:/app/var - # - ./api/frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro - # - ./api/frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro db-update: - # <<: *base-override extends: service: php - # extends: php command: php /app/mapas/src/tools/apply-updates.php depends_on: - database - ports: !override - - "8445:443" volumes: - - ./api:/app + # - ./api:/app - var-files:/app/var - frontend-build: - image: "node" - # user: "node" - working_dir: /app - # environment: - # - NODE_ENV=production - volumes: - - ./api/mapas/src:/app - # expose: - # - "8081" - # ports: # use if it is necessary to expose the container to the host machine - # - "8001:8001" - command: sh -c "npm i -g pnpm && pnpm i && pnpm run dev" - depends_on: - - php - redis: image: redis:6 restart: unless-stopped @@ -120,46 +99,43 @@ services: volumes: - sessions:/data - mailhog: + mailhog: image: mailhog/mailhog # ports: # - "8025:8025" - pwa: - image: redemapas/mapas-pwa - environment: - NEXT_PUBLIC_ENTRYPOINT: http://php + # pwa: + # image: redemapas/mapas-pwa + # build: + # context: ./pwa + # target: dev + # volumes: + # - ./pwa:/srv/app + # environment: + # API_PLATFORM_CREATE_CLIENT_ENTRYPOINT: http://php + # API_PLATFORM_CREATE_CLIENT_OUTPUT: . + # NEXT_PUBLIC_ENTRYPOINT: http://php ###> doctrine/doctrine-bundle ### database: - image: kartoza/postgis:${POSTGRES_VERSION:-14} + image: kartoza/postgis:14 environment: - - POSTGRES_DB=${POSTGRES_DB:-app} - # You should definitely change the password in production - - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-!ChangeMe!} - - POSTGRES_USER=${POSTGRES_USER:-app} - - DATADIR=/opt/postgres/data + POSTGRES_DB: ${POSTGRES_DB} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_USER: ${POSTGRES_USER} + DATADIR: ${DATADIR} volumes: - db_data:/opt/postgres/data - - ./api/mapas/dev/db:/docker-entrypoint-initdb.d + # - ./api/mapas/dev/db:/docker-entrypoint-initdb.d # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! # - ./api/docker/db/data:/var/lib/postgresql/data healthcheck: - test: "PGPASSWORD=${POSTGRES_PASSWORD} pg_isready -h 127.0.0.1 -U ${POSTGRES_USER} -d mapas" -###< doctrine/doctrine-bundle ### - -# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ### + test: "PGPASSWORD=${POSTGRES_PASSWORD} pg_isready -h 127.0.0.1 -U ${POSTGRES_USER} -d ${POSTGRES_DB}" volumes: caddy_data: caddy_config: var-files: - ###> doctrine/doctrine-bundle ### db_data: sessions: redis: -###< doctrine/doctrine-bundle ### -###> symfony/mercure-bundle ### -###< symfony/mercure-bundle ###