Skip to content

Commit

Permalink
refactor: dockerfile and add clean-up command
Browse files Browse the repository at this point in the history
Refactored the dockerfile for a better reliability and overall syntax, comment steps and added cleanup command for a weight gain of the docker image
Adapt the docker-compose to the docker hub documentation
  • Loading branch information
Gauvino committed Jun 23, 2024
1 parent 989af67 commit 9290eb3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
49 changes: 32 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
# Build image
FROM node:20-alpine AS BUILD_IMAGE

WORKDIR /app

ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}

RUN \
case "${TARGETPLATFORM}" in \
'linux/arm64' | 'linux/arm/v7') \
apk update && \
apk add --no-cache python3 make g++ gcc libc6-compat bash && \
npm install --global node-gyp \
;; \
esac

Run npm install --global pnpm
# Install OS dependencies
RUN case "${TARGETPLATFORM}" in \
'linux/arm64' | 'linux/arm/v7') \
apk update \
&& apk add --no-cache \
python3 \
make \
g++ \
gcc \
libc6-compat \
bash \
&& npm install --global node-gyp \
;; \
esac

# Install npm dependencies
RUN npm install --global pnpm

COPY package.json pnpm-lock.yaml ./
RUN CYPRESS_INSTALL_BINARY=0 pnpm install --frozen-lockfile

COPY . ./

# Git commit tag
ARG COMMIT_TAG
ENV COMMIT_TAG=${COMMIT_TAG}

RUN pnpm build

# remove development dependencies
# Remove development dependencies
RUN pnpm prune --prod --ignore-scripts

RUN rm -rf src server .next/cache
Expand All @@ -35,20 +44,26 @@ RUN touch config/DOCKER

RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json


FROM node:20-alpine
# Runtime image
FROM node:20-alpine AS RUNTIME_IMAGE

# Metadata for Github Package Registry
LABEL org.opencontainers.image.source="https://github.com/Fallenbagel/jellyseerr"
LABEL org.opencontainers.image.title="Jellyseerr"
LABEL org.opencontainers.image.description="Fork of Overseerr for Jellyfin support"

WORKDIR /app

RUN apk add --no-cache tzdata tini && rm -rf /tmp/*
# Add other dependencies and clean-up
RUN apk add --no-cache \
tzdata \
tini \
&& apk cache clean \
&& rm -rf /tmp/* /var/cache/apk/*

# copy from build image
# Copy from build image
COPY --from=BUILD_IMAGE /app ./

EXPOSE 5055
ENTRYPOINT [ "/sbin/tini", "--" ]
CMD [ "pnpm", "start" ]

EXPOSE 5055
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM node:20-alpine
COPY . /app
WORKDIR /app

Run npm install --global pnpm
RUN npm install --global pnpm

RUN pnpm install

Expand Down

0 comments on commit 9290eb3

Please sign in to comment.