File tree Expand file tree Collapse file tree 4 files changed +36
-19
lines changed
Expand file tree Collapse file tree 4 files changed +36
-19
lines changed Original file line number Diff line number Diff line change @@ -68,11 +68,11 @@ jobs:
6868 rsync -aqc docker-compose.yml ${{ secrets.ssh_connection }}:~/vectorapp/vector-portfolio/
6969 ssh -i ~/.ssh/id_rsa ${{ secrets.ssh_connection }} "
7070 cd ~/vectorapp/vector-portfolio/
71- echo "${{ env.DOMAIN }}" > .env
7271
7372 mkdir -p .secrets
74- echo "${{ secrets.payload_secret }}" > .secrets/payload-secret.txt
75- echo "${{ secrets.postgres_password }}" > .secrets/postgres-password.txt
73+ echo "${{ secrets.payload-secret }}" > .secrets/payload-secret.txt
74+ echo "${{ secrets.postgres-password }}" > .secrets/postgres-password.txt
75+ echo "${{ secrets.email-password }}" > .secrets/email-password.txt
7676 "
7777 - name : Build and push changes
7878 run : |
9494 rm nginx.tar.gz
9595
9696 export DOMAIN="${{ env.DOMAIN }}"
97+ export EMAIL_USER="${{ env.EMAIL_USER }}"
9798 docker compose up -d --no-build
9899 docker image prune -f
99100 "
Original file line number Diff line number Diff line change @@ -7,12 +7,15 @@ services:
77 - images:/app/media
88 environment :
99 - NEXT_PUBLIC_PAYLOAD_URL=https://${DOMAIN:?Website domain required}
10+ - SMTP_HOST=${SMTP_HOST:?SMTP_HOST required for email functionality}
11+ - EMAIL_USER=${EMAIL_USER:?EMAIL_USER required for email functionality}
1012 depends_on :
1113 - postgres
1214 - nginx
1315 secrets :
1416 - postgres-password
1517 - payload-secret
18+ - email-password
1619 postgres :
1720 restart : unless-stopped
1821 image : postgres:17.5-alpine
@@ -45,4 +48,6 @@ secrets:
4548 postgres-password :
4649 file : .secrets/postgres-password.txt
4750 payload-secret :
48- file : .secrets/payload-secret.txt
51+ file : .secrets/payload-secret.txt
52+ email-password :
53+ file : .secrets/email-password.txt
Original file line number Diff line number Diff line change 11import fs from 'node:fs'
22
3- // Secrets loaded from files because they're inserted at build time by docker secrets
4- // If no secret is found then read it from an environment variable (Mostly to allow for migrations and running node locally)
5- export const PAYLOAD_SECRET = ( ( ) => {
3+ function readSecret ( path : string , fallback : string = '' ) : string {
64 try {
7- return fs . readFileSync ( '/run/secrets/payload-secret' ) . toString ( )
5+ return fs . readFileSync ( path ) . toString ( )
86 } catch {
9- return process . env . PAYLOAD_SECRET || ''
7+ return fallback || ''
108 }
11- } ) ( )
9+ }
1210
13- export const DATABASE_URI = ( ( ) => {
14- try {
15- const password = fs . readFileSync ( '/run/secrets/postgres-password' ) . toString ( )
16- return `postgres://postgres: ${ password } @postgres:5432/postgres`
17- } catch {
18- return process . env . DATABASE_URI || ''
19- }
20- } ) ( )
11+ // Secrets loaded from files because they're inserted at build time by docker secrets
12+ // If no secret is found then read it from an environment variable (Mostly to allow for migrations and running node locally)
13+ export const PAYLOAD_SECRET = readSecret ( '/run/secrets/payload-secret' , process . env . PAYLOAD_SECRET )
14+
15+ export const DATABASE_URI =
16+ process . env . DATABASE_URI ||
17+ `postgres://postgres: ${ readSecret ( '/run/secrets/postgres-password' ) } @postgres:5432/postgres`
18+ export const EMAIL_PASSWORD = readSecret ( '/run/secrets/email-password' , process . env . EMAIL_PASSWORD )
Original file line number Diff line number Diff line change 11// storage-adapter-import-placeholder
22import { postgresAdapter } from '@payloadcms/db-postgres'
33import { payloadCloudPlugin } from '@payloadcms/payload-cloud'
4- import { PAYLOAD_SECRET } from './lib/secrets'
4+ import { EMAIL_PASSWORD , PAYLOAD_SECRET } from './lib/secrets'
55import { DATABASE_URI } from './lib/secrets'
6+ import { nodemailerAdapter } from '@payloadcms/email-nodemailer'
67
78import {
89 lexicalEditor ,
@@ -65,6 +66,18 @@ export default buildConfig({
6566 }
6667 : false ,
6768 } ,
69+ email : nodemailerAdapter ( {
70+ defaultFromAddress : 'contact@vectorinterior.design' ,
71+ defaultFromName : 'Vector: Interior Design' ,
72+ transportOptions : {
73+ host : process . env . SMTP_HOST ,
74+ port : 587 ,
75+ auth : {
76+ user : process . env . EMAIL_USER ,
77+ pass : EMAIL_PASSWORD ,
78+ } ,
79+ } ,
80+ } ) ,
6881 localization : {
6982 locales : [ 'en' , 'es' ] ,
7083 defaultLocale : 'es' ,
You can’t perform that action at this time.
0 commit comments