Skip to content

Commit

Permalink
Merge pull request #38 from hyperledger/fix/dockerfile
Browse files Browse the repository at this point in the history
Create a non-root user for a docker container
  • Loading branch information
alex-semenyuk authored Apr 29, 2024
2 parents a12b480 + d6b625b commit 9d47365
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE configs
.vscode
.idea
.idea

# Compiled output
firefly-tezosconnect
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ FROM golang:1.21-alpine3.19 AS builder
RUN apk add make
ARG BUILD_VERSION
ENV BUILD_VERSION=${BUILD_VERSION}
ADD . /tezosconnect
ADD --chown=1001:0 . /tezosconnect
WORKDIR /tezosconnect
RUN mkdir /.cache \
&& chgrp -R 0 /.cache \
&& chmod -R g+rwX /.cache
USER 1001
RUN make

# Copy the migrations from FFTM down into our local migrations directory
Expand All @@ -12,13 +16,16 @@ RUN DB_MIGRATIONS_DIR=$(go list -f '{{.Dir}}' github.com/hyperledger/firefly-tra

FROM debian:buster-slim
WORKDIR /tezosconnect
RUN chgrp -R 0 /tezosconnect \
&& chmod -R g+rwX /tezosconnect
RUN apt update -y \
&& apt install -y curl jq \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sL "https://github.com/golang-migrate/migrate/releases/download/$(curl -sL https://api.github.com/repos/golang-migrate/migrate/releases/latest | jq -r '.name')/migrate.linux-amd64.tar.gz" | tar xz \
&& chmod +x ./migrate \
&& mv ./migrate /usr/bin/migrate
COPY --from=builder /tezosconnect/firefly-tezosconnect /usr/bin/tezosconnect
COPY --from=builder /tezosconnect/db/ /tezosconnect/db/
COPY --from=builder --chown=1001:0 /tezosconnect/firefly-tezosconnect /usr/bin/tezosconnect
COPY --from=builder --chown=1001:0 /tezosconnect/db/ /tezosconnect/db/
USER 1001

ENTRYPOINT [ "/usr/bin/tezosconnect" ]

0 comments on commit 9d47365

Please sign in to comment.