-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.ubuntu
More file actions
47 lines (32 loc) · 1.08 KB
/
Copy pathDockerfile.ubuntu
File metadata and controls
47 lines (32 loc) · 1.08 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
# Stage 1: Build the Go application
FROM golang:1.23-alpine AS builder
# Accept build-time variables
ARG POSTGRESQL_DATABASE
ARG RELAYER_URL
# Set environment variables at runtime
ENV POSTGRESQL_DATABASE=${POSTGRESQL_DATABASE}
ENV RELAYER_URL=${RELAYER_URL}
# Set the current working directory inside the container
WORKDIR /app
# Copy the Go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# RUN go mod download github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.1
# Copy the rest of the application source code
COPY . .
# Build the Go application
RUN GOOS=linux GOARCH=amd64 go build -o main .
RUN go mod tidy
# Stage 2: Create a lightweight image to run the Go application
FROM alpine:latest
# Set the current working directory inside the container
WORKDIR /root/
# Copy the binary built in the previous stage
COPY --from=builder /app/main .
# Copy the .env file
COPY .env .
RUN apk add --no-cache bash
# Expose port if necessary (e.g., if your Go app listens on a port)
EXPOSE 8008
# Set an entrypoint or command to run the Go application
CMD ["./main"]