Skip to content

Commit

Permalink
Merge pull request #196 from SolaceProducts/DATAGO-81660-use-dedicate…
Browse files Browse the repository at this point in the history
…d-user-dockerfile

DATAGO-81660: event-management-agent Dockerfile must account for correct user and user home directory setup
  • Loading branch information
rudraneel-chakraborty authored Aug 15, 2024
2 parents 93dc032 + 4c87975 commit ecb2b23
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions service/application/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
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

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
Expand All @@ -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

Expand Down

0 comments on commit ecb2b23

Please sign in to comment.