Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create configuration files for production docker build/deployment #63

Merged
merged 16 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## This file should be used for credentials shared between development and production which are not sensitive. For shared sensitive credentials, write them in the ignored .env.local file.

# Microsoft 365 credentials
AZURE_AD_TENANT_ID=08a1a72f-fecd-4dae-8cec-471a2fb7c2f1
AZURE_AD_CLIENT_ID=76adfa07-a614-4575-a6a1-e9b59d74920a
#AZURE_AD_CLIENT_SECRET=<sensitive>

# reCaptcha credentials
NEXT_PUBLIC_RECAPTCHA=6Ld5tlYpAAAAAGp_3Y5Zp7idrOCLvPqdT2mOalfm
#RECAPTCHA_SERVER=<sensitive>
14 changes: 11 additions & 3 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# Tell NextAuth what is our app's canonical URL
NEXTAUTH_URL=http://localhost:3000
## This file should be used for development credentials which are not sensitive. For sensitive development credentials, write them in the ignored .env.development.local file.

NEXT_PUBLIC_BASE_URL=http://localhost:3000

# Configure a secret key for encrypting session tokens
# NextAuth configuration
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=dev

# Connection string for Prisma
DATABASE_URL="postgresql://taxes_app:dev_pwd@localhost:5432/taxes?schema=public"

# EuPlatesc credentials
EUPLATESC_MERCHANT_ID=44841002813
#EUPLATESC_KEY=<sensitive>
EUPLATESC_TEST_MODE=true

12 changes: 12 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## This file should be used for production credentials which are not sensitive. For sensitive production credentials, write them in the ignored .env.production.local file.

NEXT_PUBLIC_BASE_URL=https://ponou.unibuc.ro/

# NextAuth configuration
NEXTAUTH_URL=https://ponou.unibuc.ro/

# EuPlatesc credentials
EUPLATESC_MERCHANT_ID=44841002813
#EUPLATESC_KEY=<sensitive>
EUPLATESC_TEST_MODE=true

Jean-M22 marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:22

WORKDIR /app

# Install dependencies
COPY package*.json ./
RUN npm install

# Copy the source code
COPY . .

RUN npx prisma generate

# Build the production version of the app
RUN npm run build

EXPOSE 3000

CMD ["npm", "start"]
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ docker compose up
The app uses [NextAuth.js](https://next-auth.js.org/) to provide support for authentication using [Microsoft Entra ID (formerly Azure AD)](https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id). In development, you have to create a `.env.local` file in the root directory and define the following environment variables:

```
AZURE_AD_TENANT_ID=<ID of tenant in which app resides>
AZURE_AD_CLIENT_ID=<client ID of app registration>
AZURE_AD_CLIENT_SECRET=<client secret created for app>
```

Expand Down
75 changes: 75 additions & 0 deletions compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
services:
# Container for web app
web:
build: .
depends_on:
- postgres
- nginx-proxy-acme
restart: unless-stopped
networks:
- nginx-proxy
- database
environment:
DATABASE_URL: postgresql://taxes_app:dev_pwd@postgres:5432/taxes?schema=public
VIRTUAL_HOST: ponou.unibuc.ro
LETSENCRYPT_HOST: ponou.unibuc.ro

# Container for NGINX reverse proxy
nginx-proxy:
image: nginxproxy/nginx-proxy:latest
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- nginx-certs:/etc/nginx/certs
- nginx-vhost:/etc/nginx/vhost.d
- nginx-html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
- nginx-proxy
labels:
- com.github.nginx-proxy.nginx
environment:
TRUST_DOWNSTREAM_PROXY: false

# ACME companion for NGINX, for automatical TLS certificate generation
nginx-proxy-acme:
image: nginxproxy/acme-companion:latest
restart: unless-stopped
depends_on:
- nginx-proxy
volumes:
- nginx-certs:/etc/nginx/certs
- nginx-vhost:/etc/nginx/vhost.d
- nginx-html:/usr/share/nginx/html
- /etc/acme.sh
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- nginx-proxy
environment:
DEFAULT_EMAIL: contact@it.unibuc.ro

# Database container
postgres:
image: postgres:16.1
expose:
- 5432
environment:
POSTGRES_USER: taxes_app
POSTGRES_PASSWORD: dev_pwd
POSTGRES_DB: taxes
volumes:
- db-data:/var/lib/postgresql/data
networks:
- database

volumes:
nginx-certs:
nginx-vhost:
nginx-html:
db-data:

networks:
nginx-proxy:
database:
9 changes: 7 additions & 2 deletions compose.yaml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
services:
postgres:
image: "postgres:16.1"
image: postgres:16.1
ports:
- "5432:5432"
- 5432:5432
environment:
POSTGRES_USER: taxes_app
POSTGRES_PASSWORD: dev_pwd
POSTGRES_DB: taxes
volumes:
- db-data:/var/lib/postgresql/data

volumes:
db-data:
6 changes: 4 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const withNextIntl = require("next-intl/plugin")();
import createNextIntlPlugin from "next-intl/plugin";

const withNextIntl = createNextIntlPlugin();

/** @type {import('next').NextConfig} */
const nextConfig = {};

module.exports = withNextIntl(nextConfig);
export default withNextIntl(nextConfig);
Loading
Loading