diff --git a/service/application/docker/Dockerfile b/service/application/docker/Dockerfile index cfd77707..dfd19886 100644 --- a/service/application/docker/Dockerfile +++ b/service/application/docker/Dockerfile @@ -1,9 +1,21 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} +# default user name is "emauser" +ARG USER=emauser +ENV HOME /home/$USER + VOLUME /tmp -RUN mkdir -p /opt/ema && chmod 777 /opt/ema && mkdir -p /opt/ema/terraform && chmod 777 /opt/ema/terraform +# create user and directory setup +RUN adduser -D $USER && \ + mkdir -p /opt/ema && \ + chmod 777 /opt/ema && \ + mkdir -p /opt/ema/terraform && \ + chmod 777 /opt/ema/terraform && \ + chown -R $USER:$USER $HOME && \ + chown -R $USER:$USER /opt/ema/ + WORKDIR /opt/ema ARG PLATFORM=linux_amd64 @@ -11,16 +23,14 @@ ARG PLATFORM=linux_amd64 COPY tofu_1.7.0_amd64.apk /opt/ema/terraform RUN apk --update add --allow-untrusted /opt/ema/terraform/tofu_1.7.0_amd64.apk -ARG SOLACE_PROVIDER_VERSION=0.9.2-rc.2 -ADD terraform-provider-solacebroker_${SOLACE_PROVIDER_VERSION}_${PLATFORM}.tar.gz /opt/ema/terraform - -COPY .terraformrc /root/.terraformrc - +COPY .terraformrc $HOME/.terraformrc RUN printf '#!/bin/ash\ntofu $*' > /opt/ema/terraform/terraform RUN chmod +x /opt/ema/terraform/terraform - ENV PATH $PATH:/opt/ema/terraform +ARG SOLACE_PROVIDER_VERSION=0.9.2-rc.2 +ADD terraform-provider-solacebroker_${SOLACE_PROVIDER_VERSION}_${PLATFORM}.tar.gz /opt/ema/terraform + ARG GITHASH ARG GITBRANCH ARG BUILD_TIMESTAMP @@ -29,6 +39,9 @@ ENV GITHASH="${GITHASH}" \ GITBRANCH="${GITBRANCH}" \ BUILD_TIMESTAMP="${BUILD_TIMESTAMP}" +# switch to the created user from root +USER $USER + ARG JAR_FILE ADD ${JAR_FILE} app.jar