api-qobiltu-dev / Dockerfile
lifedebugger's picture
Deploy files from GitHub repository
b0f0dc1
# Gunakan image dasar Golang versi 1.24.1
FROM golang:1.24.1 AS builder
# Set working directory
WORKDIR /app
# Copy go.mod dan go.sum
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy seluruh kode
COPY . .
# Build aplikasi
# RUN go build -o /app/main .
# Build aplikasi untuk Linux
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/main .
# Stage 2: Gunakan image runtime yang lebih kecil
FROM alpine:latest
# Set working directory
WORKDIR /app
# Install tzdata
RUN apk update && apk add --no-cache tzdata
# Set the timezone environment variable
ENV TZ="Asia/Jakarta"
# Copy hasil build dari builder ke image runtime
COPY --from=builder /app/main .
# Copy folder utils (termasuk file seeder) dari builder ke runtime
COPY --from=builder /app/utils ./utils
# Copy file .env untuk konfigurasi environment
COPY .env .env
RUN chmod +x /app/main
# Jalankan aplikasi
CMD ["./main"]