Fix timezone in Dockerfile

This commit is contained in:
2024-12-23 07:42:16 +07:00
parent 7f2437a018
commit a5d96f0894

View File

@@ -1,10 +1,19 @@
FROM golang:1.23-alpine AS builder
# Install tzdata dan dependencies build
RUN apk add --no-cache tzdata build-base
#RUN apk add --no-cache tzdata build-base
# Set timezone ke Asia/Jakarta
ENV TZ=Asia/Jakarta
#ENV TZ=Asia/Jakarta
# Install tzdata package for timezone data
RUN apk add --no-cache tzdata
# Set the timezone to Asia/Jakarta
RUN cp /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && echo "Asia/Jakarta" > /etc/timezone
# Verify the timezone is set
RUN date
WORKDIR /app
@@ -13,7 +22,7 @@ COPY go.mod go.sum ./
RUN go mod tidy
# Set timezone ke Asia/Jakarta
ENV TZ=Asia/Jakarta
#ENV TZ="Asia/Jakarta"
COPY . .
@@ -23,6 +32,16 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
# Install tzdata package for timezone data
RUN apk add --no-cache tzdata
# Set the timezone to Asia/Jakarta
RUN cp /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && echo "Asia/Jakarta" > /etc/timezone
# Verify the timezone is set
RUN date
WORKDIR /root/
COPY --from=builder /app/main .