Merge pull request #48741 from chalin/chalin-im-container-local-npm-pkgs-2024-11-16

Container build: use npm ci over packages files and fix build cmd
pull/48788/head
Kubernetes Prow Robot 2024-11-20 18:04:54 +00:00 committed by GitHub
commit 0f002673e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 4 deletions

View File

@ -1 +1,3 @@
**
!package.json
!package-lock.json

View File

@ -29,8 +29,7 @@ RUN apk add --no-cache \
git \
openssh-client \
rsync \
npm && \
npm install -D autoprefixer postcss-cli
npm
RUN mkdir -p /var/hugo && \
addgroup -Sg 1000 hugo && \
@ -41,6 +40,8 @@ RUN mkdir -p /var/hugo && \
COPY --from=0 /go/bin/hugo /usr/local/bin/hugo
WORKDIR /src
COPY package.json package-lock.json ./
RUN npm ci
USER hugo:hugo

View File

@ -97,11 +97,17 @@ docker-push: ## Build a multi-architecture image and push that into the registry
rm Dockerfile.cross
container-build: module-check
$(CONTAINER_RUN) --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 $(CONTAINER_IMAGE) sh -c "npm ci && hugo --minify --environment development"
mkdir -p public
$(CONTAINER_RUN) --read-only \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
--mount type=bind,source=$(CURDIR)/public,target=/src/public $(CONTAINER_IMAGE) \
hugo --cleanDestinationDir --buildDrafts --buildFuture --environment preview --noBuildLock
# no build lock to allow for read-only mounts
container-serve: module-check ## Boot the development server using container.
$(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only --mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) hugo server --buildFuture --environment development --bind 0.0.0.0 --destination /tmp/hugo --cleanDestinationDir --noBuildLock
$(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) \
hugo server --buildFuture --environment development --bind 0.0.0.0 --destination /tmp/public --cleanDestinationDir --noBuildLock
test-examples:
scripts/test_examples.sh install