forked from ubclaunchpad/inertia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (46 loc) · 1.6 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This Dockerfile builds a tiny little image to ship the Inertia daemon in.
### Part 1 - Building the Web Client
FROM node:carbon AS web-build-env
ENV BUILD_HOME=/go/src/github.com/ubclaunchpad/inertia/daemon/web
# Mount source code.
ADD ./daemon/web ${BUILD_HOME}
WORKDIR ${BUILD_HOME}
# Build and minify client.
RUN npm install --production
RUN npm run build
### Part 2 - Building the Inertia daemon
FROM golang:alpine AS daemon-build-env
ARG INERTIA_VERSION
ENV BUILD_HOME=/go/src/github.com/ubclaunchpad/inertia \
INERTIA_VERSION=${INERTIA_VERSION}
# Mount source code.
ADD . ${BUILD_HOME}
WORKDIR ${BUILD_HOME}
# Install dependencies if not already available.
RUN if [ ! -d "vendor" ]; then \
apk add --update --no-cache git; \
go get -u github.com/golang/dep/cmd/dep; \
dep ensure -v; \
fi
# Build daemon binary.
RUN go build -o /bin/inertiad \
-ldflags "-w -s -X main.Version=$INERTIA_VERSION" \
./daemon/inertiad
### Part 3 - Copy builds into combined image
FROM alpine
LABEL maintainer "UBC Launch Pad [email protected]"
RUN mkdir -p /daemon
WORKDIR /daemon
COPY --from=daemon-build-env /bin/inertiad /usr/local/bin
COPY --from=web-build-env \
/go/src/github.com/ubclaunchpad/inertia/daemon/web/public/ \
/daemon/inertia-web
# Directories
ENV INERTIA_PROJECT_DIR=/app/host/inertia/project/ \
INERTIA_SSL_DIR=/app/host/inertia/config/ssl/ \
INERTIA_DATA_DIR=/app/host/inertia/data/ \
INERTIA_GH_KEY_PATH=/app/host/.ssh/id_rsa_inertia_deploy
# Build tool versions
ENV INERTIA_DOCKERCOMPOSE=docker/compose:1.22.0
# Serve the daemon by default.
ENTRYPOINT ["inertiad", "run"]