Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ea83b66f7 |
@@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }} is deploying ordr
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- staging
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -1,34 +1,31 @@
|
||||
# Stage 1: Build the application
|
||||
FROM golang:1.25.3-alpine AS base
|
||||
FROM golang:1.25.3-alpine AS builder
|
||||
|
||||
FROM base AS builder
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go.mod and go.sum first to leverage Docker's caching
|
||||
ENV GOPROXY=direct
|
||||
RUN apk add git
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the rest of the application source code
|
||||
COPY . .
|
||||
|
||||
# Build the Go application
|
||||
# CGO_ENABLED=0 disables Cgo for a fully static binary
|
||||
# -a links all packages statically
|
||||
# -installsuffix cgo_non_shared avoids issues with shared libraries
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build
|
||||
|
||||
RUN ls -al
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo_non_shared -o main .
|
||||
|
||||
# Stage 2: Create the final lean image
|
||||
FROM base
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy the built binary from the builder stage
|
||||
COPY --from=builder /app/ordr-api .
|
||||
COPY --from=builder /app/.env .
|
||||
COPY --from=builder /app/main .
|
||||
|
||||
# Expose the port your Gin application listens on (e.g., 8080)
|
||||
EXPOSE 8080
|
||||
|
||||
# Command to run the application
|
||||
ENV GIN_MODE=release
|
||||
CMD ["./ordr-api"]
|
||||
CMD ["./ordr-api"]
|
||||
@@ -59,8 +59,7 @@ func main() {
|
||||
|
||||
authenticator, auth_err := auth.New()
|
||||
if auth_err != nil {
|
||||
log.Printf("ERROR: Failed to initialize Authenticator %s", auth_err.Error())
|
||||
log.Fatal("ERROR: Failed to initialize authenticator...")
|
||||
log.Fatal("ERROR: Failed to initialize Authenticator")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user