Skip to content

Commit

Permalink
provide docker compose configurations and describe setup
Browse files Browse the repository at this point in the history
  • Loading branch information
toggm committed Jan 28, 2025
1 parent 509e5eb commit 0711bf9
Show file tree
Hide file tree
Showing 14 changed files with 582 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ NEXT_PUBLIC_URL=http://localhost:3000
DEFAULT_PAGE_COMPANY_NAME=MyCompany
DEFAULT_PAGE_COMPANY_ADDRESS=Homestreet 20
DEFAULT_PAGE_COMPANY_CITY=3000 Bern
DEFAULT_PAGE_COMPANY_URL=https://github.com/tegonal
DEFAULT_PAGE_COMPANY_URL=https://github.com/tegonal/cv-manager

# Provide custom logo in the public folder
DEFAULT_PAGE_COMPANY_LOGO=logo.png
Expand Down
2 changes: 1 addition & 1 deletion .env.local_postgres
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Minimal configuration to run against local postgres
DATABASE_URI=postgres://postgres:postgres@localhost:5432/tegonal-cv
DATABASE_URI=postgres://postgres:postgres@localhost:5432/cv-manager

PAYLOAD_SECRET=secret
PRINTER_SECRET=secret
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

.env
/.env
!next-env.d.ts

/media
Expand Down
71 changes: 65 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,76 @@
# CV Manager

This is a customised Payload 3 App for managing your company's CVs. It get's delivered with a pre-define generic layout which can be customized to specific needs.
This is a customised Payload 3 App for managing your company's CVs.
It gets delivered with a pre-define generic layout which can be customised to specific needs.

## Installation
## Setup

### Pre-requisits
### Pre-requisites

The application has the following dependencies:

- As a database to store the cv data. Support databases are MongoDB, Postgres or SQlite for local file based datastorage
- An S3 storage to be able to
- As a database to store the cv data. Support databases are MongoDB, Postgres or SQlite for local file based datastore
- A running [gotenberg](https://gotenberg.dev/docs/getting-started/installation) instance to generate PDF's. Use https://demo.gotenberg.dev only for low request rates and if server is public accessible.

## Customization
### Docker compose
This repository provides example docker compose configurations for a starting point to bring up your cv-manager instance.
The configurations are documented in the respective [directory](https://github.com/tegonal/cv-manager/blob/main/docker-compose).

### Configuration
The provided docker compose configurations all support a local `.env` configuration file when starting the containers. To customize the installation you therefore can download/copy the existing [`.env.example`](https://raw.githubusercontent.com/tegonal/cv-manager/refs/heads/main/.env.example) configuration to your installation and adjust the properties accordingly.

#### ⚠️ Secrets
Please provide your own strong secrets for the following environment properties used to protect and encrypt sensible data:
* `PAYLOAD_SECRET`
* `PRINTER_SECRET`

#### Database adapter

#### Enable OAuth support

#### Enable S3 storage

#### Enable SMTP mail integration

#### Customize generating PDF's

## Usage

## Development

### Local docker images
For local development, a docker-compose file is provided. You can use it through yarn:
```
nvm use
yarn run dev:compose:up
```

This will bring up a docker image for
* postgres as database adapter if running with postgres
* mongodb as database adapter if running with mongodb
* minio with initialized bucket as file storage
* mailpit as local mailserver
* gotenberg to generate PDF's locally

### Development mode with default local configuration
After starting the local docker images, the application can be run with one of the following commands, depending on the desired database adapter to use:
```
yarn run dev:mongodb
yarn run dev:postgres
yarn run dev:sqliste
```

### Development mode with custom configuration
To customize the local setup just copy the `.env.example` file to `.env`, customize it and start the server with
```
yarn run dev
```

### Database migration
If you apply any changes to the database model you need to generate the appropriate database migrations scripts for ***all*** database adapters. Run the following command to generate them:
```
yarn run migrate:create:all
```

## License

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: tegonal-cv
POSTGRES_DB: cv-manager
volumes:
- postgres-data:/var/lib/postgresql/data

Expand Down
32 changes: 32 additions & 0 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Docker compose configurations
This directory provide basic docker compose configurations to setup and start a cv-manager instance. Please adapt configurations to your needs.
Next to the docker compose file, a default `.env` file is provided. Please read in the [configuration section](https://github.com/tegonal/cv-manager/blob/main/README.md#Configuration) how to adapt those properties.

### Postgres
Ready to use setup with postgres database adapter and starting the following docker images:
* caddy as proxy server with self-signed certificates
* postgres
* gotenberg
* pgadmin (optional)
* pgbackup (optional)
* cv-manager

#### Secrets
Adjust at least the following secrets in the `.env` file to ensure you're running the instance with your own secrets:
* `PAYLOAD_SECRET`
* `PRINTER_SECRET`
* `S3_SECRET_ACCESS_KEY`
* `S3_ACCESS_KEY_ID`
* `MINIO_ROOT_PASSWORD`

#### Accessible URL
Adjust the `NEXT_PUBLIC_URL` to the URL under which the instance should be accessible and define the same hostname in the `Caddyfile` configuration.

### Run the application
Start the docker image in the desired directory:
```
docker compose up -f
```

Access

58 changes: 58 additions & 0 deletions docker-compose/mongodb/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -- Require configuration

# Please specify strong secrets for the following parms
PAYLOAD_SECRET=secret
PRINTER_SECRET=secret

# Configure for you public deployment, defaults to http://localhost:3000
# Doesn't work with gotenbergs demo instance if not pointing to a public visible url
NEXT_PUBLIC_URL=http://localhost:3000

# -- Optional configuration

# Generating the PDF documents relies on a running Gotenberg instance. For demo purposes there exist an online
# demo of the gotenberg project itself. Please provide your own instance (https://gotenberg.dev/docs/getting-started/installation)
# and configure it accordingly
GOTENBERG_PDF_URL=http://localhost:3030

# Provide a custom database URI. Supported protocols are
# postgres:// for Postgres databases
# mongodb:// for MongoDB databases
# file:// for SQLite databases
# Defaults to file:///tmp/cv_manager.db if not specified
DATABASE_URI=postgres://postgres:postgres@localhost:5432/tegonal-cv

# Use this flag with caution. This will prevent checking existence of PRINTER_SECRET in header. Use for local debug mode only
# ALLOW_UNSECURED_CV_ACCESS=false

# Uncomment if you want to connect to an S3 storage to store media files
S3_ENDPOINT=http://localhost:9000
S3_BUCKET=tegonal-cv
S3_SECRET_ACCESS_KEY=secret1234
S3_ACCESS_KEY_ID=secret1234

# Uncomment if you want to configure an integration to an oauth client
# OAUTH_CLIENT_ID=secret
# OAUTH_CLIENT_SECRET=secret
# OAUTH_TOKEN_ENDPOINT=http://localhost:8080/oauth/token
# OAUTH_AUTHORIZE_ENDPOINT=http://localhost:8080/oauth/authorize
# OAUTH_USERINFO_ENDPOINT=http://localhost:8080/oauth/userinfo

# Uncomment to be able to send out passwort reset emails, otherwise messages are written to the console log
SMTP_FROM_ADDRESS=[email protected]
SMTP_HOST=localhost
SMTP_PORT=1025
SMTP_USER=smtpuser
SMTP_PASS=smtppwd

# -- PDF layouting options, only required if you're using the default layout
# Company name used in default page
DEFAULT_PAGE_COMPANY_NAME=MyCompany
DEFAULT_PAGE_COMPANY_ADDRESS=Homestreet 20
DEFAULT_PAGE_COMPANY_CITY=3000 Bern
DEFAULT_PAGE_COMPANY_URL=https://github.com/tegonal

# Provide custom logo in the public folder
DEFAULT_PAGE_COMPANY_LOGO=logo.png
DEFAULT_PAGE_COMPANY_LOGO_WIDTH=20
DEFAULT_PAGE_COMPANY_LOGO_HEIGHT=20
89 changes: 89 additions & 0 deletions docker-compose/mongodb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: tegonal-cv

services:

mongodb:
image: mongo:8.0
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
volumes:
- mongodb-data:/data/db

minio:
image: minio/minio:latest
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: secret1234
MINIO_ROOT_PASSWORD: secret1234
volumes:
- minio-data:/data
command: server --console-address ":9001" /data

createbucket:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:9000 secret1234 secret1234;
/usr/bin/mc mb myminio/tegonal-cv;
exit 0;
"
mailpit:
image: axllent/mailpit
restart: unless-stopped
volumes:
- mailpit-data:/data
ports:
- 8025:8025
- 1025:1025
environment:
MP_MAX_MESSAGES: 100
MP_DATABASE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1

gotenberg:
image: gotenberg/gotenberg:8.15
container_name: gotenberg
command:
- "gotenberg"
- "--libreoffice-auto-start=false"
- "--libreoffice-disable-routes=true"
- "--chromium-auto-start=true"
- "--chromium-ignore-certificate-errors=true"
- "--chromium-clear-cache=true"
- "--prometheus-disable-collect=true"
- "--webhook-disable=true"
- "--pdfengines-disable-routes=true"
- "--api-port=3030"
environment:
- "TZ=Europe/Zurich"
ports:
- "3030:3030"
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:3030/health" ]
interval: 30s
timeout: 20s
retries: 3
network_mode: "host"

cvmanager:
image: tegonal/cv-manager:latest
container_name: cv-manager

volumes:
mailpit-data:
driver: local
minio-data:
driver: local
pgadmin-data:
driver: local
mongodb-data:
driver: local
87 changes: 87 additions & 0 deletions docker-compose/postgres/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# -- Require configuration

# Please specify strong secrets for the following parms
PAYLOAD_SECRET=secret
PRINTER_SECRET=secret

# Configure for you public deployment, defaults to http://localhost:3000
# Doesn't work with gotenbergs demo instance if not pointing to a public visible url
NEXT_PUBLIC_URL=https://localhost

# -- Optional configuration

# Generating the PDF documents relies on a running Gotenberg instance. For demo purposes there exist an online
# demo of the gotenberg project itself. Please provide your own instance (https://gotenberg.dev/docs/getting-started/installation)
# and configure it accordingly
GOTENBERG_PDF_URL=http://gotenberg:3000

# Provide a custom database URI. Supported protocols are
# postgres:// for Postgres databases
# mongodb:// for MongoDB databases
# file:// for SQLite databases
# Defaults to file:///tmp/cv_manager.db if not specified
DATABASE_URI=postgres://postgres:postgres@postgres:5432/cv-manager
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=cv-manager

# Use this flag with caution. This will prevent checking existence of PRINTER_SECRET in header. Use for local debug mode only
# ALLOW_UNSECURED_CV_ACCESS=false

# Uncomment if you want to connect to an S3 storage to store media files
S3_ENDPOINT=http://minio:9000
S3_BUCKET=cv-manager
S3_SECRET_ACCESS_KEY=secret1234
S3_ACCESS_KEY_ID=secret1234

# Uncomment if you want to configure an integration to an oauth client
# OAUTH_CLIENT_ID=secret
# OAUTH_CLIENT_SECRET=secret
# OAUTH_TOKEN_ENDPOINT=http://localhost:8080/oauth/token
# OAUTH_AUTHORIZE_ENDPOINT=http://localhost:8080/oauth/authorize
# OAUTH_USERINFO_ENDPOINT=http://localhost:8080/oauth/userinfo

# Uncomment to be able to send out passwort reset emails, otherwise messages are written to the console log
# [email protected]
# SMTP_HOST=localhost
# SMTP_PORT=1025
# SMTP_USER=smtpuser
# SMTP_PASS=smtppwd

# -- PDF layouting options, only required if you're using the default layout
# Company name used in default page
DEFAULT_PAGE_COMPANY_NAME=MyCompany
DEFAULT_PAGE_COMPANY_ADDRESS=Homestreet 20
DEFAULT_PAGE_COMPANY_CITY=3000 Bern
DEFAULT_PAGE_COMPANY_URL=https://github.com/tegonal/cv-manager

# Provide custom logo in the public folder
DEFAULT_PAGE_COMPANY_LOGO=logo.png
DEFAULT_PAGE_COMPANY_LOGO_WIDTH=20
DEFAULT_PAGE_COMPANY_LOGO_HEIGHT=20


# Postgres backup configuration
# DB_TYPE=pgsql
# DB_HOST=postgres
# DB_NAME=ALL
# DB_PORT=5432
# DB_USER=postgres
# DB_PASS=postgres
# DB_DUMP_FREQ=1440
# #DB_DUMP_BEGIN=0000 # <== Uncomment to set a specific time to start the backup, otherwise it will run immediately
# DB_CLEANUP_TIME=8640

# Postgres Admin configuration
# PGADMIN_DEFAULT_EMAIL=
# PGADMIN_DEFAULT_PASSWORD=

# MinIO configuration
MINIO_ROOT_USER=cv-manager
# Provide a custom password
MINIO_ROOT_PASSWORD=234rfdsklfmew90r23rmwpef23r23rwedf

# Volume backup configuration
BACKUP_FILENAME="volume-backup-%Y-%m-%dT%H-%M-%S.tar.gz"
BACKUP_LATEST_SYMLINK="volume-backup.latest.tar.gz"
BACKUP_RETENTION_DAYS="7"
Loading

0 comments on commit 0711bf9

Please sign in to comment.