-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
47 lines (34 loc) · 1.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Start from the official golang image
FROM golang:1.22-alpine AS builder
# Install Node.js and npm
RUN apk add --no-cache nodejs npm
# Set necessary environment variables
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=$TARGETPLATFORM
# Move to working directory /build
WORKDIR /build
# Copy and download dependencies using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy the rest of the code into the container
COPY . .
# Install Tailwind CSS
RUN npm install -D tailwindcss
# Generate the Tailwind CSS output
RUN npx tailwindcss -i ./static/styles/input.css -o ./static/styles/output.css --minify
# Move to the directory where main.go is located
WORKDIR /build/cmd
# Build the application
RUN go build -o /app .
# Start a new stage from scratch
FROM alpine:latest
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /app /app
# Copy the necessary files for the application
COPY --from=builder /build/static /static
COPY --from=builder /build/template /template
# Command to run the executable
CMD ["/app"]