Skip to content

Commit

Permalink
fix docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed Feb 1, 2024
1 parent bb680a1 commit 7c7d469
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ ENV PORT=3333
ENV NODE_VERSION 20.11.0-r0
ENV NPM_VERSION 10.2.5-r0

# Make sure `"type": "module"` is set in package.json
COPY --from=build /app/package.json /app/package.json
# Production dependencies
COPY --from=build /app/node_modules /app/node_modules
# Application
COPY --from=build /app/dist /app

# COPY --from=prod-deps /app/node_modules /app/node_modules
Expand Down
15 changes: 15 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'dotenv/config';
import { schema } from './env.schema.js';
import { extractErorMessage } from './utils.js';
/**
* Get environment variables
*/
export function getEnv() {
try {
return schema.parse(process.env);
} catch (error) {
console.error('Environment variables are not set correctly');
console.error(extractErorMessage(error));
process.exit(1);
}
}
6 changes: 3 additions & 3 deletions src/spy-middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dotenv/config';

import { createProxyMiddleware, responseInterceptor } from 'http-proxy-middleware';
import { schema } from './env.schema.js';
const env = schema.parse(process.env);
import { getEnv } from './env.js';
const env = getEnv();

/**
* Configure proxy middleware
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/* If NOT transpiling with TypeScript: */
// "moduleResolution": "Bundler",
// "module": "ESNext",
"noEmit": true,
// "noEmit": true,
// /* If your code runs in the DOM: */
"lib": ["es2022", "dom", "dom.iterable"],
/* If your code doesn't run in the DOM: */
Expand Down

0 comments on commit 7c7d469

Please sign in to comment.