Skip to content

Commit

Permalink
Switching to non-root user.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleplus committed Apr 18, 2024
1 parent 1a6a5d9 commit e7afcbc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dockerrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
types: [published]
workflow_dispatch:

permissions: {}

jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ jobs:
uses: super-linter/super-linter@92e2606383320f72e6129f8a50d8537cf9c84ed6 # v6.3.1
env:
VALIDATE_ALL_CODEBASE: true
LINTER_RULES_PATH: .
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions maven-check-versions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM maven:3.9.6@sha256:db0744d1d8f99bc1050f0fae6041a81fa3981fae21c383ef3d2cbb9b08faf2e6

HEALTHCHECK NONE

ENTRYPOINT []

ARG USER_NAME=default
ARG USER_HOME=/home/default
ARG USER_ID=1000
ARG USER_GECOS=Default

COPY maven-check-versions.sh /opt/

ARG MAVEN_OPTS="-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Djava.awt.headless=true"
Expand All @@ -8,4 +17,17 @@ ENV MAVEN_OPTS="${MAVEN_OPTS}"
ARG MAVEN_CLI_OPTS="--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
ENV MAVEN_CLI_OPTS="${MAVEN_CLI_OPTS}"

RUN adduser \
--home "${USER_HOME}" \
--uid "${USER_ID}" \
--gecos "${USER_GECOS}" \
--disabled-password \
"${USER_NAME}"

ENV HOME "${USER_HOME}"

USER "${USER_NAME}"

WORKDIR "${HOME}"

CMD ["/opt/maven-check-versions.sh"]
2 changes: 1 addition & 1 deletion maven-check-versions/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ services:
build:
context: .
dockerfile: Dockerfile
command: mvn -v
command: "sh -c '[ $(id -u) -ne 0 ] && mvn -v'"

0 comments on commit e7afcbc

Please sign in to comment.