forked from oseducation/knowledge-graph
/
Dockerfile.server
43 lines (31 loc) · 1.05 KB
/
Dockerfile.server
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
# Stage 1: Build Stage
FROM golang:latest AS build
# Set the working directory
WORKDIR /knowledge-graph-server
# Copy the Golang server's source code into the container
COPY ./server .
# Install any needed packages specified in go.mod and go.sum
RUN go mod download
# Build the Go application
RUN cd cmd && go build -o kg-server
# Stage 2: Runtime Stage
FROM ubuntu:22.04
# Set the working directory
WORKDIR /knowledge-graph-server
# Copy the binary from the build stage
COPY --from=build /knowledge-graph-server/cmd/kg-server .
RUN chmod +x ./kg-server
# Copy the entrypoint script
COPY ./server/entrypoint.sh .
RUN chmod +x ./entrypoint.sh
# Copy the config file
COPY ./server/config/config.json ./config/config.json
# Install jq for json config file processing
RUN apt-get update \
&& apt-get install -y jq ca-certificates curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Make port 9081 available to the world outside this container
EXPOSE 9081
# Run the server when the container launches
ENTRYPOINT ["/knowledge-graph-server/entrypoint.sh"]