diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c44dd75d..b00a7733 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,11 +13,15 @@ "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "lokalise.i18n-ally"], // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [3000, 3100, 3200, 5432], + "forwardPorts": [80, 5432], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "pnpm install", // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "node" + "remoteUser": "node", + + "features": { + "docker-from-docker": "latest" + } } diff --git a/.env.example b/.env.example index db89fbe7..fcb2de8f 100644 --- a/.env.example +++ b/.env.example @@ -1,12 +1,14 @@ -# Global +# Shared TZ=UTC +PUBLIC_URL=http://localhost +PUBLIC_SERVER_URL=http://localhost/api +PUBLIC_GOOGLE_CLIENT_ID= # Server SECRET_KEY= -PUBLIC_URL=http:// -POSTGRES_HOST=localhost +POSTGRES_HOST=postgres POSTGRES_PORT=5432 -POSTGRES_USERNAME=postgres +POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_DATABASE=postgres POSTGRES_SSL_CERT= @@ -20,12 +22,5 @@ SENDGRID_FORGOT_PASSWORD_TEMPLATE_ID= SENDGRID_FROM_NAME= SENDGRID_FROM_EMAIL= -# Client -PUBLIC_URL=http:// -PUBLIC_SERVER_URL=http:///api -PUBLIC_GOOGLE_CLIENT_ID= - -# Postgres -POSTGRES_USER=postgres -POSTGRES_PASSWORD=postgres -POSTGRES_DATABASE=postgres \ No newline at end of file +# Flags +PUBLIC_FLAG_DISABLE_SIGNUPS=false \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index 646bbe1d..00000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,71 +0,0 @@ -version: '3' - -services: - postgres: - image: postgres:14.2-alpine - container_name: postgres - ports: - - 5432:5432 - env_file: .env - volumes: - - ./scripts/database/initialize.sql:/docker-entrypoint-initdb.d/initialize.sql - - pgdata:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres" ] - interval: 30s - timeout: 30s - start_period: 15s - retries: 3 - restart: always - - traefik: - image: traefik - container_name: traefik - command: - - --providers.docker=true - - --providers.docker.exposedbydefault=false - - --entrypoints.web.address=:80 - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - server: - build: - context: . - dockerfile: server/Dockerfile - container_name: server - env_file: .env - environment: - - PUBLIC_URL=http://localhost - - POSTGRES_HOST=postgres - - POSTGRES_DATABASE=reactive_resume - depends_on: - - traefik - - postgres - labels: - - traefik.enable=true - - traefik.http.routers.server.entrypoints=web - - traefik.http.routers.server.rule=Host(`localhost`) && PathPrefix(`/api/`) - - traefik.http.routers.server.middlewares=server-stripprefix - - traefik.http.middlewares.server-stripprefix.stripprefix.prefixes=/api - - traefik.http.middlewares.server-stripprefix.stripprefix.forceslash=true - - client: - build: - context: . - dockerfile: client/Dockerfile - container_name: client - env_file: .env - environment: - - PUBLIC_SERVER_URL=http://localhost/api - depends_on: - - traefik - - server - labels: - - traefik.enable=true - - traefik.http.routers.client.rule=Host(`localhost`) - - traefik.http.routers.client.entrypoints=web - -volumes: - pgdata: diff --git a/docker-compose.yml b/docker-compose.yml index 7dc86904..6fcf456a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,46 @@ version: '3' +x-env-shared: &env-shared + environment: + - TZ=UTC + - PUBLIC_URL=http://localhost + - PUBLIC_SERVER_URL=http://localhost/api + - PUBLIC_GOOGLE_CLIENT_ID= + +x-env-server: &env-server + environment: + - SECRET_KEY= + - POSTGRES_HOST=postgres + - POSTGRES_PORT=5432 + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + - POSTGRES_DATABASE=postgres + - POSTGRES_SSL_CERT= + - JWT_SECRET= + - JWT_EXPIRY_TIME=604800 + - PUBLIC_GOOGLE_CLIENT_ID= + - GOOGLE_CLIENT_SECRET= + - GOOGLE_API_KEY= + - SENDGRID_API_KEY= + - SENDGRID_FORGOT_PASSWORD_TEMPLATE_ID= + - SENDGRID_FROM_NAME= + - SENDGRID_FROM_EMAIL= + +x-env-flags: &env-flags + environment: + - PUBLIC_FLAG_DISABLE_SIGNUPS=false + services: postgres: image: postgres:14.2-alpine container_name: postgres - ports: - - 5432:5432 - environment: - - POSTGRES_USER="postgres" - - POSTGRES_PASSWORD="postgres" - - POSTGRES_DATABASE="postgres" volumes: - pgdata:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U postgres" ] + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + start_period: 15s interval: 30s timeout: 30s - start_period: 15s retries: 3 restart: always @@ -35,32 +59,15 @@ services: server: image: amruthpillai/reactive-resume:server-latest container_name: server - environment: - - TZ="UTC" - - SECRET_KEY="" - - PUBLIC_URL="http://" - - POSTGRES_HOST="postgres" - - POSTGRES_PORT="5432" - - POSTGRES_USERNAME="postgres" - - POSTGRES_PASSWORD="postgres" - - POSTGRES_DATABASE="postgres" - - POSTGRES_SSL_CERT="" - - JWT_SECRET="" - - JWT_EXPIRY_TIME="604800" - - PUBLIC_GOOGLE_CLIENT_ID="" - - GOOGLE_CLIENT_SECRET="" - - GOOGLE_API_KEY="" - - SENDGRID_API_KEY="" # Optional - - SENDGRID_FORGOT_PASSWORD_TEMPLATE_ID="" # Optional - - SENDGRID_FROM_NAME="" # Optional - - SENDGRID_FROM_EMAIL="" # Optional + <<: *env-shared + <<: *env-server depends_on: - traefik - postgres labels: - traefik.enable=true - traefik.http.routers.server.entrypoints=web - - traefik.http.routers.server.rule=Host(``) && PathPrefix(`/api/`) + - traefik.http.routers.server.rule=Host(`localhost`) && PathPrefix(`/api/`) - traefik.http.routers.server.middlewares=server-stripprefix - traefik.http.middlewares.server-stripprefix.stripprefix.prefixes=/api - traefik.http.middlewares.server-stripprefix.stripprefix.forceslash=true @@ -69,17 +76,14 @@ services: client: image: amruthpillai/reactive-resume:client-latest container_name: client - environment: - - TZ="UTC" - - PUBLIC_URL="http://" - - PUBLIC_SERVER_URL="http:///api" - - PUBLIC_GOOGLE_CLIENT_ID="" + <<: *env-shared + <<: *env-flags depends_on: - traefik - server labels: - traefik.enable=true - - traefik.http.routers.client.rule=Host(``) + - traefik.http.routers.client.rule=Host(`localhost`) - traefik.http.routers.client.entrypoints=web restart: always diff --git a/docs/docs/source-code/env-vars.mdx b/docs/docs/source-code/env-vars.mdx index 67e7810c..18b8dd1f 100644 --- a/docs/docs/source-code/env-vars.mdx +++ b/docs/docs/source-code/env-vars.mdx @@ -65,7 +65,7 @@ This URL is used when export PDF functionality is used within the app and has to **Default Value:** `5432` **Description:** Port of the PostgreSQL Server -### `POSTGRES_USERNAME` +### `POSTGRES_USER` **Required**: `yes` **Default Value:** `postgres` diff --git a/server/src/config/config.module.ts b/server/src/config/config.module.ts index 57c11843..0c118737 100644 --- a/server/src/config/config.module.ts +++ b/server/src/config/config.module.ts @@ -21,7 +21,7 @@ const validationSchema = Joi.object({ // Database POSTGRES_HOST: Joi.string().required(), POSTGRES_PORT: Joi.number().default(5432), - POSTGRES_USERNAME: Joi.string().required(), + POSTGRES_USER: Joi.string().required(), POSTGRES_PASSWORD: Joi.string().required(), POSTGRES_DATABASE: Joi.string().required(), POSTGRES_SSL_CERT: Joi.string().allow(''), diff --git a/server/src/config/database.config.ts b/server/src/config/database.config.ts index b2fb9422..7dd1d122 100644 --- a/server/src/config/database.config.ts +++ b/server/src/config/database.config.ts @@ -3,7 +3,7 @@ import { registerAs } from '@nestjs/config'; export default registerAs('postgres', () => ({ host: process.env.POSTGRES_HOST, port: parseInt(process.env.POSTGRES_PORT, 10) || 5432, - username: process.env.POSTGRES_USERNAME, + username: process.env.POSTGRES_USER, password: process.env.POSTGRES_PASSWORD, database: process.env.POSTGRES_DATABASE, certificate: process.env.POSTGRES_SSL_CERT,