Use makefile in building for the docker container
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -1,23 +1,43 @@
|
||||
# Stage 1: Build the application
|
||||
FROM golang:1-alpine AS builder
|
||||
ARG BuiltAt
|
||||
ARG GitCommit
|
||||
ARG Version
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN apk add --no-cache bash git go gcc musl-dev curl fuse libxml2-utils
|
||||
RUN go build -ldflags "-s -w -X 'github.com/debridmediamanager/zurg/internal/version.BuiltAt=$BuiltAt' -X 'github.com/debridmediamanager/zurg/internal/version.GitCommit=$GitCommit' -X 'github.com/debridmediamanager/zurg/internal/version.Version=$Version'" -o zurg ./cmd/zurg
|
||||
|
||||
# Copy the entire project into the container
|
||||
COPY . .
|
||||
|
||||
# Install dependencies for building the application
|
||||
RUN apk add --no-cache bash git go gcc musl-dev curl fuse libxml2-utils
|
||||
|
||||
# Set build arguments
|
||||
ENV BUILT_AT=$BuiltAt
|
||||
ENV GIT_COMMIT=$GitCommit
|
||||
ENV VERSION=$Version
|
||||
|
||||
# Build the application using the Makefile
|
||||
RUN make build
|
||||
|
||||
# Stage 2: Create the runtime container
|
||||
FROM alpine:3
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built binary from the builder stage
|
||||
COPY --from=builder /app/zurg .
|
||||
|
||||
# Copy additional necessary files
|
||||
COPY ./healthcheck.sh /app/healthcheck.sh
|
||||
RUN chmod +x /app/healthcheck.sh
|
||||
COPY config.example.yml /app/config.yml
|
||||
|
||||
# Install runtime dependencies and configure FUSE
|
||||
# Ensure healthcheck script is executable
|
||||
RUN chmod +x /app/healthcheck.sh
|
||||
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache curl python3 libxml2-utils ffmpeg
|
||||
|
||||
# Set up healthcheck
|
||||
HEALTHCHECK --interval=60s --timeout=60s --start-period=10s --retries=10 CMD /app/healthcheck.sh
|
||||
|
||||
# Set the entrypoint
|
||||
ENTRYPOINT ["./zurg"]
|
||||
|
||||
6
Makefile
6
Makefile
@@ -5,9 +5,9 @@ GO ?= go
|
||||
PKG := $(shell go list ./...)
|
||||
BINARY_NAME = zurg
|
||||
BUILD_DIR = ./cmd/$(BINARY_NAME)
|
||||
VERSION := $(shell git describe --tags)
|
||||
COMMIT := $(shell git rev-parse HEAD)
|
||||
BUILT_AT := $(shell date +%Y-%m-%dT%H:%M:%SZ)
|
||||
VERSION ?= $(shell git describe --tags)
|
||||
COMMIT ?= $(shell git rev-parse HEAD)
|
||||
BUILT_AT ?= $(shell date +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Default target: build
|
||||
all: build
|
||||
|
||||
Reference in New Issue
Block a user