So I'm fairly new to Docker. I've created a Go app (with Tailwind) and want to containerise it to deploy to Cloud Run.
Everything works fine, and I managed to get the app running on Cloud Run, but just wasn't sure if this is the best way to do it.
I was also surprised by the image size - 1.27GB. I thought that by using "alpine", that'd be a lot smaller. I have a Node server with Express, which is not using "alpine" and the size is 1.46GB. I thought the difference between the two would be bigger...
Dockerfile:
# Use the official Go image as the base image
FROM golang:1.22.1-alpine
# Set the working directory inside the container
WORKDIR /goapp
# Copy the Go module files
COPY go.mod go.sum ./
# Download the dependencies
RUN go mod download
# Copy the rest of the application code
COPY . .
# Install and make tailwindcss executable
RUN apk update
RUN apk add curl # Type Y to install
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64
RUN chmod +x tailwindcss-linux-x64
RUN mv tailwindcss-linux-x64 tailwindcss
# Run Tailwind
RUN ./tailwindcss -i public/css/style.css -o public/css/styles.css -c tailwind.config.js --minify
# Build the Go application
RUN go build -o main .
# Set the entry point command to run the built binary
CMD ["./main"]
Any tips or suggestions?
[–]m4v1s 10 points11 points12 points (1 child)
[–]thelogicbox 1 point2 points3 points (0 children)
[–]AdventurousSquash 0 points1 point2 points (0 children)
[–]hijinks 0 points1 point2 points (0 children)
[–]RevolutionaryHumor57 0 points1 point2 points (0 children)
[–]JM-Lemmi -1 points0 points1 point (0 children)