init project template blueprint with websocket
This commit is contained in:
34
Dockerfile
34
Dockerfile
@@ -1,22 +1,42 @@
|
||||
FROM golang:1.23-alpine AS build
|
||||
RUN apk add --no-cache curl
|
||||
FROM golang:1.23 AS builder
|
||||
# Install curl dan Tailwind dependencies
|
||||
RUN apt-get update && apt-get install -y curl ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go.mod dan go.sum untuk dependency management
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Copy seluruh project
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main ./cmd/api
|
||||
|
||||
# Install Tailwind CSS untuk generate output.css
|
||||
RUN go install github.com/a-h/templ/cmd/templ@latest && \
|
||||
templ generate && \
|
||||
curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss && \
|
||||
chmod +x tailwindcss && \
|
||||
./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
|
||||
|
||||
RUN go build -o main cmd/api/main.go
|
||||
FROM alpine:latest
|
||||
|
||||
FROM alpine:3.20.1 AS prod
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/main /app/main
|
||||
EXPOSE ${PORT}
|
||||
# Set timezone ke Asia/Jakarta
|
||||
ENV TZ=Asia/Jakarta
|
||||
|
||||
# Install dependensi runtime yang diperlukan
|
||||
RUN apk --no-cache add ca-certificates tzdata
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy binary yang sudah ter-build dari stage sebelumnya
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/.env .
|
||||
|
||||
# Expose port aplikasi
|
||||
EXPOSE 8803
|
||||
|
||||
# Jalankan aplikasi
|
||||
CMD ["./main"]
|
||||
|
||||
Reference in New Issue
Block a user