-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (34 loc) · 1.11 KB
/
Dockerfile
File metadata and controls
47 lines (34 loc) · 1.11 KB
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
FROM public.ecr.aws/docker/library/golang:1.24.2-alpine AS build
# Install dependencies
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
# Set the working directory
WORKDIR /app
# Copy the go.mod and go.sum files
COPY go.mod go.sum ./
# Download the dependencies
RUN go mod download
# Copy the source code
COPY main.go .
# Build the Go application
RUN go build -o main .
# Use a smaller base image for the final stage
FROM alpine:latest
# Set environment variables
ENV DOCKERIZE_VERSION=v0.9.3
# Install dependencies
RUN apk update --no-cache \
&& apk add --no-cache wget openssl \
&& wget -O - https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar xzf - -C /usr/local/bin \
&& apk del wget
# set working directory
WORKDIR /app
# Copy the binary from the build stage
COPY --from=build /app/main .
COPY --from=build /go/bin/goose /usr/local/bin/goose
COPY migrations ./migrations
COPY static ./static
COPY templates ./templates
# Expose the port the app runs on
EXPOSE 8080
# Command to run the application
CMD ["./main"]