1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

Improve Docker setup and reduce memory usage of production containers (#338)

This commit is contained in:
Fynn Petersen-Frey 2022-07-13 14:42:00 +02:00 committed by GitHub
parent ae7e582ec8
commit bece6253d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 26 deletions

View File

@ -46,12 +46,12 @@ async function bootstrap() {
customSiteTitle: 'Immich API Documentation', customSiteTitle: 'Immich API Documentation',
}); });
// Generate API Documentation
const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json');
writeFileSync(outputPath, JSON.stringify(apiDocument), { encoding: 'utf8' });
await app.listen(3001, () => { await app.listen(3001, () => {
if (process.env.NODE_ENV == 'development') { if (process.env.NODE_ENV == 'development') {
// Generate API Documentation only in development mode
const outputPath = path.resolve(process.cwd(), 'immich-openapi-specs.json');
writeFileSync(outputPath, JSON.stringify(apiDocument), { encoding: 'utf8' });
Logger.log('Running Immich Server in DEVELOPMENT environment', 'ImmichServer'); Logger.log('Running Immich Server in DEVELOPMENT environment', 'ImmichServer');
} }

View File

@ -7,7 +7,7 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"scripts": { "scripts": {
"prebuild": "rimraf dist", "prebuild": "rimraf dist",
"build": "nest build", "build": "nest build immich && nest build microservices",
"format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"", "format": "prettier --write \"apps/**/*.ts\" \"libs/**/*.ts\"",
"start": "nest start", "start": "nest start",
"start:dev": "nest start --watch", "start:dev": "nest start --watch",

View File

@ -1 +1 @@
npm start microservices node dist/apps/microservices/apps/microservices/src/main

View File

@ -1 +1 @@
npm start immich node dist/apps/immich/apps/immich/src/main

View File

@ -5,35 +5,23 @@ WORKDIR /usr/src/app
RUN chown node:node /usr/src/app RUN chown node:node /usr/src/app
COPY --chown=node:node package*.json ./ RUN apk add --no-cache setpriv
RUN apk add --update-cache build-base python3 COPY --chown=node:node package*.json ./
RUN npm ci RUN npm ci
COPY --chown=node:node . . COPY --chown=node:node . .
EXPOSE 3000 EXPOSE 3000
EXPOSE 24678
FROM base AS dev FROM base AS dev
ENV CHOKIDAR_USEPOLLING=true ENV CHOKIDAR_USEPOLLING=true
EXPOSE 24678
CMD ["npm", "run", "dev"] CMD ["npm", "run", "dev"]
FROM node:16-alpine3.14 as prod FROM base as prod
ENV NODE_ENV=production
WORKDIR /usr/src/app
RUN chown node:node /usr/src/app
COPY --chown=node:node package*.json ./
COPY --chown=node:node . .
RUN apk add --update-cache build-base python3
RUN npm ci
EXPOSE 3000
# Issue build command in entrypoint.sh to capture user .env file instead of the builder .env file. # Issue build command in entrypoint.sh to capture user .env file instead of the builder .env file.

View File

@ -1 +1,6 @@
npm run build && node /usr/src/app/build/index.js npm run build
if [ `id -u` -eq 0 ] && [ -n "$PUID" ] && [ -n "$PGID" ]; then
exec setpriv --reuid $PUID --regid $PGID --clear-groups node /usr/src/app/build/index.js
else
node /usr/src/app/build/index.js
fi

View File

@ -1,7 +1,7 @@
import type { GetSession, Handle } from '@sveltejs/kit'; import type { GetSession, Handle } from '@sveltejs/kit';
import * as cookie from 'cookie'; import * as cookie from 'cookie';
import { api } from '@api'; import { api } from '@api';
import { AxiosError } from 'axios'; import AxiosError from 'axios';
export const handle: Handle = async ({ event, resolve }) => { export const handle: Handle = async ({ event, resolve }) => {
const cookies = cookie.parse(event.request.headers.get('cookie') || ''); const cookies = cookie.parse(event.request.headers.get('cookie') || '');