-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
656 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
# Docker related files | ||
.dockerignore | ||
Dockerfile* | ||
docker-compose.yml | ||
|
||
# Documentation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
inx-mqtt | ||
go.work | ||
go.work.sum | ||
|
||
# IDE related files | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# https://hub.docker.com/_/golang | ||
FROM golang:1.21-bullseye AS build | ||
|
||
# Ensure ca-certificates are up to date | ||
RUN update-ca-certificates | ||
|
||
# Set the current Working Directory inside the container | ||
RUN mkdir /scratch | ||
WORKDIR /scratch | ||
|
||
# Prepare the folder where we are putting all the files | ||
RUN mkdir /app | ||
|
||
# Copy everything from the current directory to the PWD(Present Working Directory) inside the container | ||
COPY . . | ||
|
||
# Download go modules | ||
RUN go mod download | ||
RUN go mod verify | ||
|
||
# Build the binary (disable inlining and optimizations that can interfere with debugging) | ||
RUN CGO_ENABLED=0 go build -a -gcflags "all=-N -l" -o /app/inx-mqtt . | ||
|
||
# Copy the assets | ||
COPY ./config_defaults.json /app/config.json | ||
|
||
############################ | ||
# Image | ||
############################ | ||
FROM golang:1.21-alpine | ||
|
||
# Install delve | ||
RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest | ||
|
||
# Create the nonroot user | ||
ARG USERNAME=nonroot_user | ||
ARG USER_UID=65532 | ||
ARG USER_GID=$USER_UID | ||
ARG USER_HOME=/home/nonroot | ||
RUN addgroup --g $USER_GID $USERNAME && adduser --disabled-password --uid $USER_UID --ingroup "${USERNAME}" --shell /sbin/nologin --home $USER_HOME $USERNAME | ||
|
||
EXPOSE 1883/tcp | ||
EXPOSE 1888/tcp | ||
# Delve | ||
EXPOSE 4000 | ||
|
||
# Copy the app dir into distroless image | ||
COPY --chown=nonroot:nonroot --from=build /app /app | ||
|
||
WORKDIR /app | ||
|
||
# Set USER nonroot | ||
USER $USERNAME | ||
|
||
ENTRYPOINT [ "/go/bin/dlv", "--listen=:4000", "--headless=true", "--log=true", "--accept-multiclient", "--api-version=2", "exec", "/app/inx-mqtt", "--" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.