Skip to content

Commit

Permalink
Add .dockerfile for docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
imoore76 committed Apr 27, 2024
1 parent eb8bc01 commit 9e5270e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.22 as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

RUN mkdir /build
WORKDIR /build/
ADD . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o ldlm-server ./cmd/server/
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o ldlm-lock ./cmd/lock/

FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:bookworm-slim
COPY --from=builder /build/ldlm-server /usr/bin/ldlm-server
COPY --from=builder /build/ldlm-lock /usr/bin/ldlm-lock

LABEL org.opencontainers.image.source=https://github.com/imoore76/go-ldlm
LABEL org.opencontainers.image.description="LDLM server"
LABEL org.opencontainers.image.licenses="Apache 2.0"

ENV LDLM_LISTEN_ADDRESS="0.0.0.0:3144" LDLM_IPC_SOCKET_FILE="/tmp/ldlm-ipc.sock"
EXPOSE "3144/tcp"

RUN set -eux; \
groupadd -r ldlm --gid=999; \
useradd -r -g ldlm --uid=999 --home-dir=/home/ldlm --shell=/bin/bash ldlm; \
mkdir -p /home/ldlm

WORKDIR /home/ldlm

USER ldlm:ldlm

CMD ["/usr/bin/ldlm-server"]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!/.gitignore
!/.github
!/.goreleaser.yaml
!/.dockerfile
/build
/dist

Expand Down

0 comments on commit 9e5270e

Please sign in to comment.