Skip to content

Commit

Permalink
chore: fixup docker image building
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Sep 26, 2024
1 parent bb982af commit a6b9aac
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_media
.ffmpeg
.coverage
deploy
dist
node_modules
pouch__all_dbs__
36 changes: 26 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
FROM node:18
FROM node:18 AS builder
WORKDIR /usr/src/app
ENV NODE_ENV production
ENV PATHS__FFMPEG ffmpeg
ENV PATHS__FFPROBE ffmpeg

COPY package.json package-lock.json ./
RUN sed -i -e 's/^ "version": "[0-9.]\+",$//' package.json
RUN yarn install && \
apt-get update && \
apt-get install ffmpeg -y
COPY package.json yarn.lock .yarnrc.yml ./
RUN sed -i -e 's/^ "version": "[0-9.]\+",$//' package.json
RUN corepack enable

COPY ./src ./src
COPY tsconfig.build.json ./

RUN yarn install
RUN yarn build:ts

RUN sed -i -e 's/^ "postinstall": "husky",$//' package.json
RUN yarn workspaces focus --production

FROM node:18
WORKDIR /usr/src/app
ENV NODE_ENV=production
ENV PATHS__FFMPEG=ffmpeg
ENV PATHS__FFPROBE=ffmpeg

RUN apt-get update && \
apt-get install ffmpeg -y && \
rm -rf /var/lib/apt/lists/*

CMD [ "node", "src" ]
COPY --from=builder /usr/src/app/package.json ./
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/node_modules ./node_modules

CMD [ "node", "dist" ]
HEALTHCHECK CMD curl -f http://localhost:8000/healthcheck || exit 1
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"build-linux-arm64": "run build linux arm64",
"build-linux-x64": "run build linux x64",
"build-win32-x64": "run build win32 x64",
"build:docker": "docker build .",
"lint:raw": "run eslint --ext .ts --ext .js --ext .tsx --ext .jsx --ext .mts --ext .mjs --ignore-pattern dist",
"lint": "yarn lint:raw .",
"lint-fix": "yarn lint --fix",
Expand Down

0 comments on commit a6b9aac

Please sign in to comment.