Container build with NPM deps and fixed build cmd

pull/48741/head
Patrice Chalin 2024-11-16 08:11:29 -05:00
parent 3a69da0139
commit 9d1d3323cd
3 changed files with 13 additions and 4 deletions

View File

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

View File

@ -31,8 +31,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 && \
@ -43,6 +42,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