build(docker): minimize production docker image size by using ubuntu:focal

This commit is contained in:
Amruth Pillai
2022-03-07 21:43:38 +01:00
parent c738f311da
commit b0a295d8bb
15 changed files with 91 additions and 44 deletions
+7 -3
View File
@@ -24,15 +24,19 @@ COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=dependencies /app/schema/node_modules ./schema/node_modules
COPY --from=dependencies /app/server/node_modules ./server/node_modules
RUN [[ -e .env ]] && cp .env ./server/.env
RUN pnpm run build:schema
RUN pnpm run build:server
FROM mcr.microsoft.com/playwright:focal as production
FROM ubuntu:focal as production
WORKDIR /app
RUN apt-get update \
&& apt-get install -y curl g++ make \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash \
&& apt-get install -y nodejs \
&& npx playwright install-deps chromium
RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
COPY --from=builder /app/pnpm-*.yaml .
+2 -2
View File
@@ -5,6 +5,6 @@ export default registerAs('app', () => ({
environment: process.env.NODE_ENV,
secretKey: process.env.SECRET_KEY,
port: parseInt(process.env.SERVER_PORT, 10) || 3100,
url: process.env.APP_URL || 'http://localhost:3000',
serverUrl: process.env.SERVER_URL || 'http://localhost:3100',
url: process.env.PUBLIC_APP_URL || 'http://localhost:3000',
serverUrl: process.env.PUBLIC_SERVER_URL || 'http://localhost:3100',
}));
+8 -6
View File
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { ConfigModule as NestConfigModule } from '@nestjs/config';
import * as Joi from 'joi';
import Joi from 'joi';
import appConfig from './app.config';
import authConfig from './auth.config';
@@ -16,8 +16,8 @@ const validationSchema = Joi.object({
NODE_ENV: Joi.string().valid('development', 'production').default('development'),
// URLs
APP_URL: Joi.string().default('http://localhost:3000'),
SERVER_URL: Joi.string().default('http://localhost:3100'),
PUBLIC_APP_URL: Joi.string().default('http://localhost:3000'),
PUBLIC_SERVER_URL: Joi.string().default('http://localhost:3100'),
// Database
POSTGRES_HOST: Joi.string().required(),
@@ -31,14 +31,16 @@ const validationSchema = Joi.object({
JWT_SECRET: Joi.string().required(),
JWT_EXPIRY_TIME: Joi.number().required(),
// Google
GOOGLE_API_KEY: Joi.string().allow(''),
// Mail
MAIL_HOST: Joi.string().allow(''),
MAIL_PORT: Joi.number().default(465),
MAIL_USERNAME: Joi.string().allow(''),
MAIL_PASSWORD: Joi.string().allow(''),
// Google
GOOGLE_API_KEY: Joi.string().allow(''),
GOOGLE_CLIENT_SECRET: Joi.string().allow(''),
PUBLIC_GOOGLE_CLIENT_ID: Joi.string().allow(''),
});
@Module({
+1 -1
View File
@@ -2,6 +2,6 @@ import { registerAs } from '@nestjs/config';
export default registerAs('google', () => ({
apiKey: process.env.GOOGLE_API_KEY,
clientId: process.env.GOOGLE_CLIENT_ID,
clientId: process.env.PUBLIC_GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}));