-
Notifications
You must be signed in to change notification settings - Fork 0
/
latest.Dockerfile
145 lines (124 loc) · 4.75 KB
/
latest.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
FROM debian:bullseye-slim@sha256:f576b8067b77ff85c70725c976b7b6cde960898e2f19b9abab3fb148407614e2 as build
# Many thanks to biscuitWizard for supplying modifications to improve the docker image.
# Also thanks to Zig for testing the image and pushing for new feature support.
# Lastly huge thanks to Lisdude for overhauling the dynamic parameter building script.
# Make directories, copy binary & scripts
RUN mkdir -p /home/moo
RUN mkdir -p /home/moo-init
RUN mkdir -p /home/moorepo
RUN mkdir -p /home/repobackup
# Copy our scripts to execute the moo
COPY ./startup.sh /usr/local/bin/startup
COPY ./restart.latest.sh /usr/local/bin/restart
COPY ./buildParameters.sh /usr/local/bin/buildParameters
# Download the latest toast core
ADD https://raw.githubusercontent.com/lisdude/toastcore/master/toastcore.db /home/moo-init/moo.db
RUN cp /home/moo-init/moo.db /home/moo/moo.db
# Install the various dependent packages
RUN apt-get update && \
apt-get install -y \
bison \
build-essential \
cmake \
git \
gperf \
libargon2-0-dev \
libaspell-dev \
libcurl4-openssl-dev \
libexpat1-dev \
libpcre3-dev \
libpq-dev \
libpq5 \
libsqlite3-dev \
libssl-dev \
nettle-dev
# upgrading CMAKE version to be the latest and greatest.
WORKDIR /opt
ADD https://github.com/Kitware/CMake/releases/download/v3.24.0-rc4/cmake-3.24.0-rc4-linux-x86_64.sh cmake-build.sh
RUN chmod +x cmake-build.sh
RUN yes | ./cmake-build.sh
RUN apt remove -y --purge cmake
RUN ln -s /opt/cmake-3.24.0-rc4-linux-x86_64/bin/* /usr/local/bin
# Now we need to compile libpqxx for postgres support.
RUN git clone https://github.com/jtv/libpqxx.git
WORKDIR /opt/libpqxx
RUN git checkout 7.6
RUN pwd ; cmake . && make -j2 && make install
# Pull the latest repo of the ToastStunt server source
ADD https://api.github.com/repos/lisdude/toaststunt/compare/master...HEAD /dev/null
RUN git clone https://github.com/lisdude/toaststunt /home/moorepo
# Clone the repo for fresh setups with a mapped volume and build the server
RUN cp -R /home/moorepo/* /home/repobackup
# Build the server and copy our binary to the bin directory
RUN mkdir /home/moorepo/build
WORKDIR /home/moorepo/build
RUN cmake ../
RUN make -j2
RUN cp moo /usr/local/bin/moo
# Fix permissions on our various binaries and scripts just in case it is needed (but generally it will not be)
RUN chmod +x /usr/local/bin/moo && \
chmod 777 /usr/local/bin/moo && \
chmod +x /usr/local/bin/buildParameters && \
chmod 777 /usr/local/bin/buildParameters && \
chmod +x /usr/local/bin/restart && \
chmod 777 /usr/local/bin/restart
FROM debian:bullseye-slim@sha256:f576b8067b77ff85c70725c976b7b6cde960898e2f19b9abab3fb148407614e2 as final
LABEL org.opencontainers.image.authors="Thaddeus Ryker <thad@edgerunner.org>"
LABEL version="latest"
LABEL description="This is the latest version of ToastStunt server packaged with the latest Toast core"
LABEL core="Toast"
# build command:
# docker build -f latest.Dockerfile -t wiredwizard/toaststunt:latest .
# Copy all our various files and directories now that all has been built
COPY --from=build /usr/local/bin/ /usr/local/bin/
COPY --from=build /home/ /home/
COPY --from=build /usr/local/lib/libpqxx* /usr/local/lib/
COPY --from=build /opt/ /opt/
# Install the various dependent packages
RUN apt-get update && \
apt-get install -y \
bison \
build-essential \
#cmake \
git \
gperf \
libargon2-0-dev \
libaspell-dev \
libcurl4-openssl-dev \
libexpat1-dev \
libpcre3-dev \
libpq-dev \
libpq5 \
libsqlite3-dev \
libssl-dev \
nettle-dev
# Install Tini for us to use to insure a graceful shutdown of the moo
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
# Install gosu to run at reduced permissions
RUN set -eux; \
apt-get install -y gosu; \
rm -rf /var/lib/apt/lists/*; \
# verify that the binary works
gosu nobody true
# Set our default variables
ENV TZ="America/New_York"
ENV PORT="7777"
# I added 7778 as the default exposed TLS port
EXPOSE ${PORT}/tcp 7778/tcp
# Change our stop signal so that we can ensure a safe shutdown of the moo when the container stops
STOPSIGNAL SIGINT
# Create our moo user and group
RUN \
groupadd -o --gid 10001 moo && \
useradd -u 10000 -g moo -d /home/moo moo && \
usermod -G users moo && \
chown -R moo:moo /home/* && \
chown moo:moo /usr/local/bin/moo && \
chown moo:moo /usr/local/bin/startup && \
chown moo:moo /usr/local/bin/restart && \
chown moo:moo /usr/local/bin/buildParameters
# Set directory to our moo and execute the restart script via Tini for clean process control
WORKDIR /home/moo
ENTRYPOINT ["/tini", "-g", "-v", "--", "startup", "moo"]