fix: actually run the backend as a non-root user
This commit is contained in:
parent
18602a42f1
commit
46bc60351c
3 changed files with 6 additions and 2 deletions
|
@ -12,12 +12,15 @@ USER $BUILD_UID
|
||||||
WORKDIR $BUILD
|
WORKDIR $BUILD
|
||||||
RUN --mount=type=cache,target=$MAVEN_HOME/.m2,uid=$BUILD_UID \
|
RUN --mount=type=cache,target=$MAVEN_HOME/.m2,uid=$BUILD_UID \
|
||||||
mvn -e -Duser.home=$MAVEN_HOME package
|
mvn -e -Duser.home=$MAVEN_HOME package
|
||||||
|
USER 0
|
||||||
|
RUN chown -R root $BUILD
|
||||||
|
|
||||||
FROM openjdk:7u211-jre-alpine AS backend
|
FROM openjdk:7u211-jre-alpine AS backend
|
||||||
RUN <<EOF
|
RUN <<EOF
|
||||||
set -e
|
set -e
|
||||||
mkdir -p /app/state
|
mkdir -p /app/state
|
||||||
chown -R 1000 /app/state
|
touch /app/data-source.xml
|
||||||
|
chown -R 1000 /app/state /app/data-source.xml
|
||||||
EOF
|
EOF
|
||||||
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/*.jar /app/server.jar
|
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/*.jar /app/server.jar
|
||||||
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/lib /app/lib
|
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/lib /app/lib
|
||||||
|
|
|
@ -8,7 +8,7 @@ run_init_command() {
|
||||||
if ! [ -f state/init-$stage ]; then
|
if ! [ -f state/init-$stage ]; then
|
||||||
echo "Running initialization stage $stage"
|
echo "Running initialization stage $stage"
|
||||||
echo " --> $*"
|
echo " --> $*"
|
||||||
if /app/entrypoint.sh tool "$*"
|
if /app/entrypoint.sh tool $*
|
||||||
then
|
then
|
||||||
touch state/init-$stage
|
touch state/init-$stage
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,6 +25,7 @@ services:
|
||||||
dockerfile: docker/Dockerfile.application
|
dockerfile: docker/Dockerfile.application
|
||||||
target: backend
|
target: backend
|
||||||
restart: always
|
restart: always
|
||||||
|
user: "1000"
|
||||||
volumes:
|
volumes:
|
||||||
- init-state:/app/state
|
- init-state:/app/state
|
||||||
environment:
|
environment:
|
||||||
|
|
Loading…
Add table
Reference in a new issue