-
Notifications
You must be signed in to change notification settings - Fork 16
/
worker-dockerfile
33 lines (24 loc) · 893 Bytes
/
worker-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
# Use an official Go runtime as a parent image
FROM golang:1.21
# Install Protobuf compiler and Go-related packages
RUN apt-get update && apt-get install -y \
protobuf-compiler \
golang-go \
git
# Install the protoc-gen-go and protoc-gen-go-grpc plugins
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# Set the working directory in the container
WORKDIR /app
# Copy the go.mod and go.sum files first to leverage Docker cache
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the local package files to the container's workspace.
COPY pkg/ ./pkg/
COPY cmd/worker/main.go .
RUN ./pkg/grpcapi/build.sh
# Build the worker application
RUN go build -o worker main.go
# Run the worker when the container launches
CMD ["./worker", "--coordinator=coordinator:8080"]