-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
36 lines (29 loc) · 1.08 KB
/
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
34
35
36
# ============================== BINARY BUILDER ==============================
FROM golang:latest as builder
# Copy in the source
COPY . /src
WORKDIR /src
# Download and Install Tensorflow CPU
RUN mkdir local && \
curl -L https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.3.1.tar.gz | \
tar -C local -xz && \
cp -a local /usr
# Vendor, Test and Build the Binary
RUN GO111MODULE=on go mod vendor
RUN go test ./...
RUN CGO_ENABLED=1 go build -o ./bin/server
# ================================ FINAL IMAGE ================================
FROM ubuntu:latest
# Dependencies
RUN apt-get update -y && \
apt-get upgrade -y
# Copy Tensorflow
COPY --from=builder /src/local /usr
ENV LIBRARY_PATH $LIBRARY_PATH:/usr/local/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib
# Copy Graph/Labels, static files and Binary
COPY --from=builder /src/graph /graph
COPY --from=builder /src/service/templates /service/templates
COPY --from=builder /src/service/static /service/static
COPY --from=builder /src/bin/server /usr/local/bin/server
CMD ["server"]