Skip to content

Refactor to avoid unnecessary multi-stage build #109

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

Merged
merged 1 commit into from
Jan 4, 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
32 changes: 13 additions & 19 deletions 1.0/18-alpine3.17/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,34 @@

# https://nodejs.org/en/about/releases/
# https://github.com/nodejs/Release#readme
FROM node:18-alpine3.17 as builder

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN apk -U add git
RUN git clone --depth 1 --branch $MONGO_EXPRESS_VERSION https://github.com/mongo-express/mongo-express.git /app
WORKDIR /app

RUN yarn install
RUN yarn build

FROM node:18-alpine3.17

ARG MONGO_EXPRESS_VERSION=v1.0.2

RUN set -eux; \
apk -U add --no-cache \
apk add --no-cache \
bash \
# grab tini for signal processing and zombie killing
tini

# Copy app from builder image
COPY --from=builder /app /app
WORKDIR /app

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN set -eux; \
apk add --no-cache --virtual .me-fetch-deps git; \
git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/mongo-express/mongo-express.git .; \
export DISABLE_V8_COMPILE_CACHE=1; \
yarn install; \
yarn build; \
apk del --no-network .me-fetch-deps; \
rm -rf .git* ~/.cache ~/.yarn

# override some config defaults with values that will work better for docker
ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \
ME_CONFIG_SITE_SESSIONSECRET="secret" \
VCAP_APP_HOST="0.0.0.0"

WORKDIR /app

EXPOSE 8081
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"]
CMD ["mongo-express"]
32 changes: 13 additions & 19 deletions 1.0/18-alpine3.18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,34 @@

# https://nodejs.org/en/about/releases/
# https://github.com/nodejs/Release#readme
FROM node:18-alpine3.18 as builder

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN apk -U add git
RUN git clone --depth 1 --branch $MONGO_EXPRESS_VERSION https://github.com/mongo-express/mongo-express.git /app
WORKDIR /app

RUN yarn install
RUN yarn build

FROM node:18-alpine3.18

ARG MONGO_EXPRESS_VERSION=v1.0.2

RUN set -eux; \
apk -U add --no-cache \
apk add --no-cache \
bash \
# grab tini for signal processing and zombie killing
tini

# Copy app from builder image
COPY --from=builder /app /app
WORKDIR /app

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN set -eux; \
apk add --no-cache --virtual .me-fetch-deps git; \
git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/mongo-express/mongo-express.git .; \
export DISABLE_V8_COMPILE_CACHE=1; \
yarn install; \
yarn build; \
apk del --no-network .me-fetch-deps; \
rm -rf .git* ~/.cache ~/.yarn

# override some config defaults with values that will work better for docker
ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \
ME_CONFIG_SITE_SESSIONSECRET="secret" \
VCAP_APP_HOST="0.0.0.0"

WORKDIR /app

EXPOSE 8081
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"]
CMD ["mongo-express"]
32 changes: 13 additions & 19 deletions 1.0/20-alpine3.17/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,34 @@

# https://nodejs.org/en/about/releases/
# https://github.com/nodejs/Release#readme
FROM node:20-alpine3.17 as builder

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN apk -U add git
RUN git clone --depth 1 --branch $MONGO_EXPRESS_VERSION https://github.com/mongo-express/mongo-express.git /app
WORKDIR /app

RUN yarn install
RUN yarn build

FROM node:20-alpine3.17

ARG MONGO_EXPRESS_VERSION=v1.0.2

RUN set -eux; \
apk -U add --no-cache \
apk add --no-cache \
bash \
# grab tini for signal processing and zombie killing
tini

# Copy app from builder image
COPY --from=builder /app /app
WORKDIR /app

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN set -eux; \
apk add --no-cache --virtual .me-fetch-deps git; \
git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/mongo-express/mongo-express.git .; \
export DISABLE_V8_COMPILE_CACHE=1; \
yarn install; \
yarn build; \
apk del --no-network .me-fetch-deps; \
rm -rf .git* ~/.cache ~/.yarn

# override some config defaults with values that will work better for docker
ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \
ME_CONFIG_SITE_SESSIONSECRET="secret" \
VCAP_APP_HOST="0.0.0.0"

WORKDIR /app

EXPOSE 8081
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"]
CMD ["mongo-express"]
32 changes: 13 additions & 19 deletions 1.0/20-alpine3.18/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,34 @@

# https://nodejs.org/en/about/releases/
# https://github.com/nodejs/Release#readme
FROM node:20-alpine3.18 as builder

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN apk -U add git
RUN git clone --depth 1 --branch $MONGO_EXPRESS_VERSION https://github.com/mongo-express/mongo-express.git /app
WORKDIR /app

RUN yarn install
RUN yarn build

FROM node:20-alpine3.18

ARG MONGO_EXPRESS_VERSION=v1.0.2

RUN set -eux; \
apk -U add --no-cache \
apk add --no-cache \
bash \
# grab tini for signal processing and zombie killing
tini

# Copy app from builder image
COPY --from=builder /app /app
WORKDIR /app

ARG MONGO_EXPRESS_VERSION=release/v1.0.2

RUN set -eux; \
apk add --no-cache --virtual .me-fetch-deps git; \
git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/mongo-express/mongo-express.git .; \
export DISABLE_V8_COMPILE_CACHE=1; \
yarn install; \
yarn build; \
apk del --no-network .me-fetch-deps; \
rm -rf .git* ~/.cache ~/.yarn

# override some config defaults with values that will work better for docker
ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \
ME_CONFIG_SITE_SESSIONSECRET="secret" \
VCAP_APP_HOST="0.0.0.0"

WORKDIR /app

EXPOSE 8081
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"]
CMD ["mongo-express"]
30 changes: 13 additions & 17 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
# https://nodejs.org/en/about/releases/
# https://github.com/nodejs/Release#readme
FROM node:{{ env.variant }} as builder

ARG MONGO_EXPRESS_VERSION=release/v{{ .version }}

RUN apk -U add git
RUN git clone --depth 1 --branch $MONGO_EXPRESS_VERSION https://github.com/mongo-express/mongo-express.git /app
WORKDIR /app

RUN yarn install
RUN yarn build

FROM node:{{ env.variant }}

RUN set -eux; \
apk -U add --no-cache \
apk add --no-cache \
bash \
# grab tini for signal processing and zombie killing
tini

# Copy app from builder image
COPY --from=builder /app /app
WORKDIR /app

ARG MONGO_EXPRESS_VERSION=release/v{{ .version }}

RUN set -eux; \
apk add --no-cache --virtual .me-fetch-deps git; \
git clone --depth 1 --branch "$MONGO_EXPRESS_VERSION" -c advice.detachedHead=false https://github.com/mongo-express/mongo-express.git .; \
export DISABLE_V8_COMPILE_CACHE=1; \
yarn install; \
yarn build; \
apk del --no-network .me-fetch-deps; \
rm -rf .git* ~/.cache ~/.yarn

# override some config defaults with values that will work better for docker
ENV ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
ME_CONFIG_MONGODB_ENABLE_ADMIN="true" \
ME_CONFIG_SITE_SESSIONSECRET="secret" \
VCAP_APP_HOST="0.0.0.0"

WORKDIR /app

EXPOSE 8081
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT [ "/sbin/tini", "--", "/docker-entrypoint.sh"]
CMD ["mongo-express"]