-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
40 lines (27 loc) · 942 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.21-alpine3.19 AS builder
RUN mkdir /app
ADD . /app
WORKDIR /app
RUN apk add --no-cache git
ARG GOPROXY
# download deps before gobuild
RUN go mod download -x
ARG TARGETOS
ARG TARGETARCH
RUN source ./scripts/version.sh && \
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -v -o 2mqtt -ldflags "-s -w $LD_FLAGS" cmd/main.go
FROM alpine:3.19
LABEL maintainer="Jeeva Kandasamy <jkandasa@gmail.com>"
ENV APP_HOME="/app" \
DATA_HOME="/mc_home"
# install timzone utils
RUN apk --no-cache add tzdata
# create a user and give permission for the locations
RUN mkdir -p ${APP_HOME} && mkdir -p ${DATA_HOME}
# copy application bin file
COPY --from=builder /app/2mqtt ${APP_HOME}/2mqtt
RUN chmod +x ${APP_HOME}/2mqtt
# copy default files
COPY ./resources/sample-config.yaml ${APP_HOME}/config.yaml
WORKDIR ${APP_HOME}
CMD ["/app/2mqtt", "--config", "/app/config.yaml"]