now up and running using docker

This commit is contained in:
2025-04-17 15:22:55 +02:00
parent 5337da219e
commit 22b6f3bd2a
10 changed files with 80 additions and 117 deletions

View File

@@ -1,32 +1,26 @@
# Use official Golang image
FROM golang:1.20-alpine as builder
# Stage 1: Build the Go binary
FROM golang:1.21-alpine AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
# Copy go.mod and go.sum first
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum are not changed
RUN go mod download
# Copy the source code into the container
COPY src src
# Copy the rest of the code
COPY . .
# Build the Go app
RUN go build -o main src
# Build the Go binary
RUN go build -o wagfarm-api main.go
# Start a new stage from a smaller image
FROM alpine:latest
# Stage 2: Minimal runtime image
FROM alpine:latest
# Install required libraries
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the pre-built binary file from the builder stage
COPY --from=builder /app/main .
# Copy the binary from the builder
COPY --from=builder /app/wagfarm-api .
# Expose the API port
EXPOSE 8089
# Run the Go app
CMD ["./main"]
# Run the binary
CMD ["./wagfarm-api"]
#CMD ["tail", "-f", "/dev/null"]