diff --git a/compose.benefit-backend.yml b/compose.benefit-backend.yml new file mode 100644 index 0000000000..6fe1872d9f --- /dev/null +++ b/compose.benefit-backend.yml @@ -0,0 +1,65 @@ +version: "3.8" +name: yjdh-benefit +services: + postgres: + build: + context: ./backend + dockerfile: ./docker/finnish_postgres.Dockerfile + restart: on-failure + environment: + POSTGRES_USER: benefit + POSTGRES_PASSWORD: benefit + POSTGRES_DB: benefit + LC_COLLATE: "fi_FI.UTF-8" + LC_CTYPE: "fi_FI.UTF-8" + ports: + - 5434:5432 + volumes: + - pgdata:/var/lib/postgresql/data + container_name: benefit-db + + backend: + build: + context: ./backend + dockerfile: ./docker/benefit.Dockerfile + target: development + env_file: + - .env.benefit-backend + environment: + DATABASE_URL: postgres://benefit:benefit@benefit-db/benefit + DATABASE_HOST: benefit-db.helsinki + volumes: + - ./backend/benefit:/app + - ./backend/shared:/shared + depends_on: + - postgres + container_name: benefit-backend + + local-proxy: + depends_on: + - postgres + - backend + build: + context: ./localdevelopment/benefit/nginx + container_name: benefit-local-proxy + volumes: + - ./localdevelopment/benefit/nginx/:/etc/nginx/ + ports: + - 127.0.0.1:8000:8000 + + mailhog: + image: "mailhog/mailhog@sha256:8d76a3d4ffa32a3661311944007a415332c4bb855657f4f6c57996405c009bea" + ports: + - 1025:1025 + - 8025:8025 + container_name: benefit-mailhog + networks: + - default + +volumes: + pgdata: + driver: local + +networks: + default: + name: helsinki diff --git a/frontend/benefit/.gitignore b/frontend/benefit/.gitignore new file mode 100644 index 0000000000..d4baa33405 --- /dev/null +++ b/frontend/benefit/.gitignore @@ -0,0 +1 @@ +certificates/ \ No newline at end of file diff --git a/frontend/shared/src/server/next-server.js b/frontend/shared/src/server/next-server.js index c5975d6f92..73220b4126 100644 --- a/frontend/shared/src/server/next-server.js +++ b/frontend/shared/src/server/next-server.js @@ -1,6 +1,7 @@ const express = require('express'); const next = require('next'); - +const https = require('https'); +const fs = require('fs'); const port = process.env.PORT || 3000; const app = next({ dev: process.env.NODE_ENV !== 'production' }); const handle = app.getRequestHandler(); @@ -41,7 +42,27 @@ const checkIsServerReady = (response) => { server.get('*', (req, res) => handle(req, res)); - await server.listen(port); + if (process.env.NEXT_SERVE_WITH_CUSTOM_CERTS) { + let options; + try { + options = { + key: fs.readFileSync( + process.cwd() + '/../../shared/src/server/localhost.key' + ), + cert: fs.readFileSync( + process.cwd() + '/../../shared/src/server/localhost.crt' + ), + }; + } catch (e) { + console.error( + 'No certificate file(s) found. Copy it from the local-proxy container.' + ); + return; + } + https.createServer(options, server).listen(port); + } else { + await server.listen(port); + } signalReady(); console.log(`> Ready on https://localhost:${port}`); // eslint-disable-line no-console })(); diff --git a/localdevelopment/benefit/nginx/html/500.html b/localdevelopment/benefit/nginx/html/500.html new file mode 100644 index 0000000000..7bc6d637d6 --- /dev/null +++ b/localdevelopment/benefit/nginx/html/500.html @@ -0,0 +1,56 @@ + +
+ + +