Skip to content

[REFACTOR] [CONFIG] Dockerfile optimizations #526

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 2 commits into from
Sep 7, 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
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
###############################################################################
FROM node:22.8.0-alpine3.20 AS base

RUN apk add --update --no-cache make
RUN apk upgrade --update --no-cache openssl libcrypto3 libssl3 # FIX CVE-2024-5535
RUN apk add --update --no-cache make \
&& apk upgrade --update --no-cache openssl libcrypto3 libssl3 # FIX CVE-2024-5535

ENV WORKDIR=/app
WORKDIR ${WORKDIR}
Expand All @@ -13,10 +13,9 @@ FROM base AS lint
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN apk add --update --no-cache make nodejs npm
RUN apk add --update --no-cache yamllint

RUN npm install -g --ignore-scripts markdownlint-cli
RUN apk add --update --no-cache make nodejs npm \
&& apk add --update --no-cache yamllint \
&& npm install -g --ignore-scripts markdownlint-cli

# [!TIP] Use a bind-mount to "/app" to override following "copys"
# for lint and test against "current" sources in this stage
Expand Down Expand Up @@ -121,8 +120,8 @@ COPY ./Makefile ${WORKDIR}/
COPY ./package.json ${WORKDIR}/package.json
COPY ./package-lock.json ${WORKDIR}/package-lock.json

RUN npm ci --verbose --omit=dev --omit=optional --ignore-scripts --no-cache
RUN ls -alh
RUN npm ci --verbose --omit=dev --omit=optional --ignore-scripts --no-cache \
&& ls -alh

USER node
CMD ["ls", "-alh"]
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,35 @@ update: dependencies outdated
upgrade: update

compose/build: env
docker-compose --profile lint build
docker-compose --profile testing build
docker-compose --profile production build
${DOCKER_COMPOSE} --profile lint build
${DOCKER_COMPOSE} --profile testing build
${DOCKER_COMPOSE} --profile production build

compose/rebuild: env
docker-compose --profile lint build --no-cache
docker-compose --profile testing build --no-cache
docker-compose --profile production build --no-cache
${DOCKER_COMPOSE} --profile lint build --no-cache
${DOCKER_COMPOSE} --profile testing build --no-cache
${DOCKER_COMPOSE} --profile production build --no-cache

compose/lint/markdown: compose/build
docker-compose --profile lint build
docker-compose --profile lint run --rm algorithm-exercises-js-lint make lint/markdown
${DOCKER_COMPOSE} --profile lint build
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-js-lint make lint/markdown

compose/lint/yaml: compose/build
docker-compose --profile lint run --rm algorithm-exercises-js-lint make lint/yaml
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-js-lint make lint/yaml

compose/test/styling: compose/build
docker-compose --profile lint run --rm algorithm-exercises-js-lint make test/styling
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-js-lint make test/styling

compose/test/static: compose/build
docker-compose --profile lint run --rm algorithm-exercises-js-lint make test/static
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-js-lint make test/static

compose/lint: compose/lint/markdown compose/lint/yaml compose/test/styling compose/test/static

compose/test: compose/build
docker-compose --profile testing run --rm algorithm-exercises-js-test make test
${DOCKER_COMPOSE} --profile testing run --rm algorithm-exercises-js-test make test

compose/run: compose/build
docker-compose --profile production run --rm algorithm-exercises-js make run
${DOCKER_COMPOSE} --profile production run --rm algorithm-exercises-js make run

all: env dependencies test

Expand Down