Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Don't install dev packages in Docker image #575

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# Base stage
FROM node:18-alpine AS base

ENV CHROME_BIN="/usr/bin/chromium-browser"
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"

WORKDIR /usr/src/app

RUN \
apk --no-cache upgrade && \
apk add --no-cache udev ttf-opensans unifont chromium ca-certificates dumb-init && \
rm -rf /tmp/*
RUN apk --no-cache upgrade && \
apk add --no-cache udev ttf-opensans unifont chromium ca-certificates dumb-init && \
rm -rf /tmp/*

FROM base as build
# Build stage
FROM base AS build

COPY . ./

RUN yarn install --pure-lockfile
RUN yarn run build

EXPOSE 8081
# Production dependencies stage
FROM base AS prod-dependencies

CMD [ "yarn", "run", "dev" ]
COPY package.json yarn.lock ./
RUN yarn install --pure-lockfile --production

# Final stage
FROM base

LABEL maintainer="Grafana team <hello@grafana.com>"
Expand All @@ -38,7 +42,7 @@ RUN addgroup -S -g $GF_GID grafana && \

ENV NODE_ENV=production

COPY --from=build /usr/src/app/node_modules node_modules
COPY --from=prod-dependencies /usr/src/app/node_modules node_modules
COPY --from=build /usr/src/app/build build
COPY --from=build /usr/src/app/proto proto
COPY --from=build /usr/src/app/default.json config.json
Expand Down
10 changes: 7 additions & 3 deletions debian.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ RUN apt-get install -y wget gnupg \
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init

# Build stage
FROM base as build

COPY . ./

RUN yarn install --pure-lockfile
RUN yarn run build

EXPOSE 8081
# Production dependencies stage
FROM base AS prod-dependencies

CMD [ "yarn", "run", "dev" ]
COPY package.json yarn.lock ./
RUN yarn install --pure-lockfile --production

# Final stage
FROM base

ENV NODE_ENV=production

COPY --from=build /usr/src/app/node_modules node_modules
COPY --from=prod-dependencies /usr/src/app/node_modules node_modules
COPY --from=build /usr/src/app/build build
COPY --from=build /usr/src/app/proto proto
COPY --from=build /usr/src/app/default.json config.json
Expand Down