Skip to content

Commit

Permalink
Merge pull request #34 from The-Debarghya/add_dockerfile
Browse files Browse the repository at this point in the history
Dockerized version of metabigor
  • Loading branch information
j3ssie authored Feb 19, 2024
2 parents be443a0 + fbbcca9 commit 2362747
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github/*
.gitignore
.goreleaser.yml
LICENSE
README.md
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM golang:latest-bullseye AS builder

# Build Args
ARG BUILD_COMMAND="go build -o metabigor ."
ARG BINARY_NAME="metabigor"
ARG CGO_ENABLED="0"
# Env setup
ENV CGO_ENABLED=${CGO_ENABLED}

# Setup workdir
WORKDIR /build

# Copy source code
COPY . .

# Fetch dependencies
RUN apt install build-essential
RUN go mod download

RUN go build -o ${BINARY_NAME} .

# Runner stage
FROM golang:latest-alpine AS runner

# Build Args
ARG BINARY_NAME="metabigor"
ARG START_COMMAND="./metabigor"

# Setup workdir
WORKDIR /app
RUN useradd -D metabigor
RUN chown -R metabigor:metabigor /app

# Copy binary
COPY --from=builder /build/${BINARY_NAME} .

# Create entrypoint
RUN echo ${START_COMMAND} > /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
USER metabigor

# Setup Entrypoint
ENTRYPOINT ["sh", "-c", "/user/entrypoint.sh"]

0 comments on commit 2362747

Please sign in to comment.