File tree Expand file tree Collapse file tree 4 files changed +43
-11
lines changed
Expand file tree Collapse file tree 4 files changed +43
-11
lines changed Original file line number Diff line number Diff line change 77 runs-on : ubuntu-latest
88 steps :
99 - name : Checkout the code
10- uses : actions/checkout@v2
10+ uses : actions/checkout@v4
1111
1212 - name : Docker login
13- uses : docker/login-action@v2
13+ uses : docker/login-action@v3
1414 with :
1515 username : ${{ secrets.DOCKER_USERNAME }}
1616 password : ${{ secrets.DOCKER_PASSWORD }}
1717
18+ - name : Verify secrets
19+ run : |
20+ if [ -z "${{ secrets.DATABASE_URL }}" ]; then
21+ echo "Error: DATABASE_URL secret is not set"
22+ exit 1
23+ fi
24+ if [ -z "${{ secrets.JWT_SECRET }}" ]; then
25+ echo "Error: JWT_SECRET secret is not set"
26+ exit 1
27+ fi
28+
1829 - name : Build and push
19- uses : docker/build-push-action@v4
30+ uses : docker/build-push-action@v5
2031 with :
2132 context : .
2233 file : ./docker/Dockerfile.frontend
Original file line number Diff line number Diff line change 11import type { NextConfig } from "next" ;
2+ import { webpack } from "next/dist/compiled/webpack/webpack" ;
23
34const nextConfig : NextConfig = {
45 /* config options here */
@@ -10,6 +11,18 @@ const nextConfig: NextConfig = {
1011 publicRuntimeConfig : {
1112 JWT_SECRET : process . env . JWT_SECRET ,
1213 } ,
14+
15+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16+ webpack : ( config , { isServer } ) => {
17+ // Ensure environment variables are always available
18+ config . plugins . push (
19+ new webpack . DefinePlugin ( {
20+ 'process.env.JWT_SECRET' : JSON . stringify ( process . env . JWT_SECRET ) ,
21+ 'process.env.DATABASE_URL' : JSON . stringify ( process . env . DATABASE_URL ) ,
22+ } )
23+ ) ;
24+ return config ;
25+ }
1326} ;
1427
1528export default nextConfig ;
Original file line number Diff line number Diff line change @@ -58,10 +58,12 @@ export const authOptions: NextAuthOptions = {
5858 token . id = user . id ;
5959 token . email = user . email ;
6060 }
61-
61+ if ( ! process . env . JWT_SECRET ) {
62+ throw new Error ( "JWT_SECRET is ABSOLUTELY REQUIRED and not set" ) ;
63+ }
6264 token . accessToken = jwt . sign (
6365 { id : token . id , email : token . email } ,
64- process . env . NEXT_PUBLIC_JWT_SECRET || "" ,
66+ process . env . JWT_SECRET ,
6567 { expiresIn : "7d" }
6668 ) ;
6769 return token ;
@@ -75,5 +77,5 @@ export const authOptions: NextAuthOptions = {
7577 return session ;
7678 } ,
7779 } ,
78- secret : process . env . NEXT_PUBLIC_JWT_SECRET ,
80+ secret : process . env . JWT_SECRET ,
7981} ;
Original file line number Diff line number Diff line change @@ -9,11 +9,6 @@ WORKDIR /usr/src/app
99ARG DATABASE_URL
1010ARG JWT_SECRET
1111
12- # Set environment variables
13- ENV DATABASE_URL=${DATABASE_URL}
14- ENV JWT_SECRET=${JWT_SECRET}
15- ENV NEXT_PUBLIC_JWT_SECRET=${JWT_SECRET}
16-
1712# Copy necessary files for dependency installation
1813COPY ./packages ./packages
1914COPY ./package.json ./package.json
@@ -38,6 +33,17 @@ RUN prisma generate
3833# Change back to the root directory
3934WORKDIR /usr/src/app
4035
36+ # Set environment variables
37+ ENV DATABASE_URL=${DATABASE_URL}
38+ ENV JWT_SECRET=${JWT_SECRET}
39+
40+ # Debugging step
41+ RUN echo "DATABASE_URL length: ${#DATABASE_URL}"
42+ RUN echo "JWT_SECRET length: ${#JWT_SECRET}"
43+
44+ # Fail if secrets are not set
45+ RUN test -n "$DATABASE_URL" && test -n "$JWT_SECRET"
46+
4147# Debug step: print environment variables
4248RUN echo "DATABASE_URL: ${DATABASE_URL}" && echo "JWT_SECRET set: ${JWT_SECRET:+yes}"
4349
You can’t perform that action at this time.
0 commit comments