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

Create non-root user #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ jobs:
HUGO_VERSION=v${{ steps.release.outputs.version }}
HUGO_EXTENDED=${{ matrix.extended }}

- name: Check container user
if: steps.needs-build.outputs.build == true
run: |
WHOAMI=$(docker run --rm hugomods/hugo:test whoami)
echo $WHOAMI
if [[ "$WHOAMI" != "hugo" ]]
then
echo "Expected user "hugo", got "$WHOAMI"." && exit 1;
fi

- id: hugo-version
name: Save Hugo version for subsequent tests.
if: steps.needs-build.outputs.build == true
Expand Down
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-dart-sass-base
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ INCLUDE+ ./Dockerfile-builder

FROM alpine:edge

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/dart-sass

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-dart-sass-git
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ INCLUDE+ ./Dockerfile-builder

FROM alpine:edge

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/dart-sass

INCLUDE+ ./snippets/git

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-dart-sass-go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ INCLUDE+ ./Dockerfile-builder

FROM alpine:edge

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/dart-sass

INCLUDE+ ./snippets/go

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-dart-sass-go-git
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ INCLUDE+ ./Dockerfile-builder

FROM alpine:edge

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/dart-sass

INCLUDE+ ./snippets/git

INCLUDE+ ./snippets/go

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-git
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ INCLUDE+ ./Dockerfile-builder

FROM alpine

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/git

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-go-git
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ INCLUDE+ ./Dockerfile-builder

FROM golang:alpine

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/git

INCLUDE+ ./snippets/common
4 changes: 2 additions & 2 deletions docker/hugo/Dockerfile-node-git
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ INCLUDE+ ./Dockerfile-builder

FROM node:alpine

INCLUDE+ ./snippets/common

INCLUDE+ ./snippets/git

INCLUDE+ ./snippets/common
9 changes: 9 additions & 0 deletions docker/hugo/snippets/common
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# this code snippet MUST be placed at the end of Dockerfile.
ARG HUGO_EXTENDED=

# libc6-compat & libstdc++ are required for extended SASS libraries
Expand All @@ -9,7 +10,15 @@ RUN apk add --update --no-cache ca-certificates
COPY --from=builder /usr/bin/hugo /usr/bin/hugo

# working directory.
RUN mkdir /src
WORKDIR /src

# create non-root user
RUN deluser --remove-home node || true
RUN addgroup -g 1000 hugo \
&& adduser -u 1000 -G hugo -s /bin/sh -D hugo
RUN chown -R hugo:hugo /src
USER hugo:hugo

# default command.
CMD hugo env
Loading