Change ownership not working for key.pem

This commit is contained in:
tobsec 2022-11-02 17:44:51 +01:00 committed by GitHub
parent 43eb2d5f47
commit ad6be6da14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,9 @@ FROM golang as builder
RUN apt-get update && apt-get install -y libpam-dev
# add user
RUN adduser --disabled-password --gecos "" --home /opt/rdpgw --uid 1001 rdpgw
# certificate
RUN mkdir -p /opt/rdpgw && cd /opt/rdpgw && \
random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) && \
@ -13,9 +16,6 @@ RUN mkdir -p /opt/rdpgw && cd /opt/rdpgw && \
-subj "/C=US/ST=VA/L=SomeCity/O=MyCompany/OU=MyDivision/CN=rdpgw" && \
openssl x509 -req -days 365 -in server.csr -signkey key.pem -out server.pem
# add user
RUN adduser --disabled-password --gecos "" --home /opt/rdpgw --uid 1001 rdpgw
# build rdpgw and set rights
ARG CACHEBUST
RUN git clone https://github.com/bolkedebruin/rdpgw.git /app && \
@ -25,20 +25,20 @@ RUN git clone https://github.com/bolkedebruin/rdpgw.git /app && \
CGO_ENABLED=1 GOOS=linux go build -trimpath -tags '' -ldflags '' -o '/opt/rdpgw/rdpgw-auth' ./cmd/auth && \
chmod +x /opt/rdpgw/rdpgw && \
chmod +x /opt/rdpgw/rdpgw-auth && \
chmod u+s /opt/rdpgw/rdpgw-auth && \
chown -R 1001 /opt/rdpgw
chmod u+s /opt/rdpgw/rdpgw-auth
FROM scratch
# make tempdir in case filestore is used
ADD tmp.tar /
COPY --from=builder /opt/rdpgw /opt/rdpgw
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
COPY rdpgw.yaml /opt/rdpgw/rdpgw.yaml
USER 1001
COPY --chown=1001 --from=builder /opt/rdpgw /opt/rdpgw
COPY --chown=1001 --from=builder /etc/passwd /etc/passwd
COPY --chown=1001 --from=builder /etc/ssl/certs /etc/ssl/certs
COPY --chown=1001 rdpgw.yaml /opt/rdpgw/rdpgw.yaml
WORKDIR /opt/rdpgw
ENTRYPOINT ["/opt/rdpgw/rdpgw"]