1
+ FROM golang:1.9-alpine
2
+
3
+ # Install curl, git
4
+ RUN apk add --no-cache curl, git
5
+
6
+ # Configure DB
7
+ ENV DB_DIALECT="postgres" \
8
+ DB_CONNECTION_STRING="postgresql://spacedock:spacedock@host/spacedock?sslmode=disable" \
9
+ REDIS_STRING="redis://localhost:6379/0"
10
+
11
+ # SpaceDock Backend repository location
12
+ ENV SDB_REPOSITORY="github.com/KSP-SpaceDock/SpaceDock-Backend"
13
+
14
+ # Make the source code path
15
+ RUN mkdir -p /go/src/$SDB_REPOSITORY
16
+
17
+ # Add all source code
18
+ ADD . /go/src/$SDB_REPOSITORY
19
+
20
+ # Change working dir to app location
21
+ WORKDIR /go/src/$SDB_REPOSITORY
22
+
23
+ # Add plugins.txt
24
+ RUN touch build/plugins.txt
25
+
26
+ # Install Glide for package management
27
+ RUN curl https://glide.sh/get | sh
28
+
29
+ # Fetch plugins
30
+ RUN chmod +x build/fetch_plugins.sh
31
+ RUN sh build/fetch_plugins.sh
32
+
33
+ # Setup configuration file
34
+ RUN cp config/config.example.yml config/config.yml \
35
+ && sed -i 's!postgres\b !$DB_DIALECT!g' config/config.yml \
36
+ && sed -i 's!postgresql://user:password@host/dbname?sslmode=disable!$DB_CONNECTION_STRING!g' config/config.yml \
37
+ && sed -i 's!redis://localhost:6379/0!$REDIS_STRING!g' config/config.yml
38
+
39
+ # Install dependencies
40
+ RUN glide install
41
+
42
+ # Build the app
43
+ RUN go build -v -o sdb build_sdb.go
44
+
45
+ RUN mkdir /output/ \
46
+ && mkdir /output/config \
47
+ && cp sdb /output/sdb \
48
+ && cp config/config.yml /output/config.yml
49
+
50
+
51
+
52
+ # Setup actual app
53
+ FROM alpine
54
+ WORKDIR /app
55
+ COPY --from=builder /output/sdb /app/sdb
56
+ COPY --from=builder /output/config.yml /app/config/config.yml
57
+
58
+ ENTRYPOINT ['./app/sdb' ]
59
+
60
+ EXPOSE 5000
0 commit comments