Created
July 1, 2017 05:33
-
-
Save jamesandersen/2f3d95a0d407f49f561013c067c48e19 to your computer and use it in GitHub Desktop.
Multi-stage Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BUILD the app in first stage | |
FROM jamesandersen/alpine-golang-opencv3:edge | |
RUN apk --no-cache add git | |
WORKDIR /go/src/github.com/jamesandersen/gosudoku | |
COPY . . | |
RUN go get github.com/nytimes/gziphandler | |
RUN go-wrapper download # "go get -d -v ./..." | |
RUN go-wrapper install # "go install -v ./..." | |
# Start from a *NEW* image in the second stage | |
FROM alpine:edge # We're discarding all the GO SDK tooling at this point! | |
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories | |
RUN apk --no-cache add ca-certificates opencv-libs | |
RUN ln /usr/lib/libopencv_core.so.3.2.0 /usr/lib/libopencv_core.so \ | |
&& ln /usr/lib/libopencv_highgui.so.3.2.0 /usr/lib/libopencv_highgui.so \ | |
&& ln /usr/lib/libopencv_imgcodecs.so.3.2.0 /usr/lib/libopencv_imgcodecs.so \ | |
&& ln /usr/lib/libopencv_imgproc.so.3.2.0 /usr/lib/libopencv_imgproc.so \ | |
&& ln /usr/lib/libopencv_ml.so.3.2.0 /usr/lib/libopencv_ml.so \ | |
&& ln /usr/lib/libopencv_objdetect.so.3.2.0 /usr/lib/libopencv_objdetect.so \ | |
&& ln /usr/lib/libopencv_photo.so.3.2.0 /usr/lib/libopencv_photo.so | |
WORKDIR /root/ | |
# ** MAGIC HAPPENS HERE! ** | |
# We can grab the binary built in the previous stage and copy it to our "clean" image | |
COPY --from=0 /go/bin/gosudoku . | |
COPY web ./web | |
# Set the PORT environment variable inside the container | |
ENV PORT 8080 | |
# Expose port 8080 to the host so we can access our application | |
EXPOSE 8080 | |
CMD ["./gosudoku"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment