-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
77 lines (63 loc) · 2.65 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM debian:jessie
# This docker file is only useful if you wish to build the pi-gateway on non ARM64 platforms
# for example (x86_64), and OSes to generate cross platform binaries that can run on the Pi 3
# using debian jessie.
#
# If you are already on a Pi 3 then all that is needed is to install the go compiler, and
# run 'go install .' inside the top level directory of the cloned github repo.
#
# This Dockerfile fulfils one additional purpose and that is to provide an accurate record
# from development of every dependency needed to compile and run the pi-gateway
#
# To build the docker image for the build something such as the following would be used. You only
# need to do this once!. The use of the USER... variables allows the docker build to use your
# local user id when accessing and generating the binaries. Most OSes will have these already defined
# for your USER the exception being Mac OSX which probably goes without saying.
#
# docker build -t magnus_build --build-arg USER=$USER --build-arg USER_ID=`id -u $USER` --build-arg USER_GROUP_ID=`id -g $USER` .
#
# To run the built container to cross compile to ARM64 after making source changes, from the top of the
# github source repository directory
#
# docker run --cap-drop=all -it -v `pwd`:/project -u `id -u $USER`:`id -g $GROUP` -e LOCAL_USER_ID=`id -u $USER` magnus_build
#
MAINTAINER [email protected]
ENV LANG C.UTF-8
ARG USER
ENV USER ${USER}
ARG USER_ID
ENV USER_ID ${USER_ID}
ARG USER_GROUP_ID
ENV USER_GROUP_ID ${USER_GROUP_ID}
ENV INITSYSTEM on
RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils && \
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure apt-utils && \
apt-get install -y pulseaudio alsa-utils mplayer wget curl jq git sudo bash zsh && \
apt-get upgrade -y && \
apt-get dist-upgrade -y && \
echo "exit-idle-time = -1" >> /etc/pulse/daemon.conf
# Add the build environment for compiled Go
RUN wget --quiet -O /tmp/go.tgz https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz && \
tar xzf /tmp/go.tgz
RUN echo ${USER}
RUN groupadd -f -g ${USER_GROUP_ID} ${USER}
RUN useradd -g ${USER_GROUP_ID} -u ${USER_ID} -ms /bin/bash ${USER}
USER ${USER}
WORKDIR /home/${USER}
RUN mkdir -p /home/${USER}/.ssh && \
chmod 0700 /home/${USER}/.ssh && \
ssh-keyscan github.com >> /home/${USER}/.ssh/known_hosts
ENV PATH=$PATH:/home/${USER}/go/bin
ENV GOROOT=/home/${USER}/go
ENV GOPATH=/project
ENV GOBIN=/project/bin
RUN cd /home/${USER} && \
mkdir -p /home/${USER}/go && \
tar xzf /tmp/go.tgz
VOLUME /project
WORKDIR /project
ENV GOOS linux
ENV GOARCH arm
ENV GOARM 7
CMD go get -d . && go build -o bin/pi-gateway.arm .