forked from open-horizon/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.amd64
57 lines (41 loc) · 1.58 KB
/
Dockerfile.amd64
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
53
54
55
56
57
#
# Blue Horizon Firmware Device API: gps
#
# This server provides REST access to gps receiver location and satellite data
#
# More precise documentation of the behavior of this container may be found
# in the src/main.go source code.
#
# To build this server container, run the following command in this directory:
# $ make
#
# To run the firmware container as a daemon process (e.g., so you can test it):
# $ make daemon
#
# To run the firmware container in dev mode (normally used for development):
# $ make develop
#
# Written by Glen Darling, November 2016.
#
# Build stage 0: Go compilation
FROM golang:1.15-alpine as go_build
RUN apk --no-cache update && apk add git
RUN mkdir -p /build/bin
COPY src /build/src
WORKDIR /build
RUN env GOPATH=/build GOOPTIONS_AMD64='CGO_ENABLED=0 GOOS=linux GOARCH=amd64' go get github.com/kellydunn/golang-geo
RUN env GOPATH=/build GOOPTIONS_AMD64='CGO_ENABLED=0 GOOS=linux GOARCH=amd64' go build -o /build/bin/amd64_gps /build/src/main.go
# Build stage 1: The final container (including armv6_gps binary from above)
FROM alpine:latest
# Install the gpsd daemon, and the certs needed to use https services
RUN apk update && apk add gpsd curl --no-cache ca-certificates
# Copy in the server binary from stage 0 of the build (above)
COPY --from=0 /build/bin/amd64_gps /gps
# Create hzngroup and hznuser
RUN addgroup -S hzngroup && adduser -S hznuser -G hzngroup
# Run container as hznuser user
USER hznuser
# The gps service uses this port to respond to REST requests
EXPOSE 8080
# Set the default command to be the go executable to start everything
CMD /gps