Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
163 lines (149 loc) · 4.98 KB
/
Copy pathDockerfile
File metadata and controls
163 lines (149 loc) · 4.98 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# syntax=docker/dockerfile:1.7
FROM ubuntu:24.04 AS dependencies
ARG DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ENV TZ=Etc/UTC
ARG VCPKG_FEED_URL
ARG VCPKG_FEED_USERNAME
ARG VCPKG_BINARY_CACHE_ACCESS=read
ARG VCPKG_BINARY_SOURCES
ENV VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES}
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
autoconf \
autoconf-archive \
automake \
build-essential \
ca-certificates \
cmake \
curl \
git \
jq \
libgl1-mesa-dev \
libglu1-mesa-dev \
libltdl-dev \
libtool \
libtool-bin \
libx11-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxrandr-dev \
linux-libc-dev \
make \
mono-complete \
ninja-build \
perl \
pkg-config \
python3 \
tar \
tzdata \
unzip \
zip \
&& ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime \
&& echo "${TZ}" > /etc/timezone \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt
COPY vcpkg.json /opt/vcpkg.json
RUN vcpkgCommitId="$(jq -r '."builtin-baseline"' vcpkg.json)" \
&& echo "vcpkg commit ID: ${vcpkgCommitId}" \
&& git clone https://github.com/microsoft/vcpkg.git \
&& cd vcpkg \
&& git checkout "${vcpkgCommitId}" \
&& ./bootstrap-vcpkg.sh
WORKDIR /opt/vcpkg_manifest
COPY vcpkg.json vcpkg-configuration.json /opt/vcpkg_manifest/
# Keep the manifest's overlay port available to both published and CI-only Docker builds.
COPY overlay-ports /opt/vcpkg_manifest/overlay-ports/
RUN --mount=type=secret,id=github_token,required=false \
--mount=type=cache,target=/opt/vcpkg/downloads \
--mount=type=cache,target=/opt/vcpkg/buildtrees \
--mount=type=cache,target=/opt/vcpkg/packages \
--mount=type=cache,target=/root/.cache/vcpkg \
/bin/bash -euo pipefail -c '\
nuget_config=""; \
if [ -s /run/secrets/github_token ] && [ -n "${VCPKG_FEED_URL:-}" ] && [ -n "${VCPKG_FEED_USERNAME:-}" ]; then \
cache_access="${VCPKG_BINARY_CACHE_ACCESS:-read}"; \
case "${cache_access}" in read|readwrite) ;; *) cache_access="read";; esac; \
nuget_auth_token="$(cat /run/secrets/github_token)"; \
nuget_config="/tmp/nuget.config"; \
printf "%s\n" \
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
"<configuration>" \
" <packageSources>" \
" <add key=\"GitHubPackages\" value=\"${VCPKG_FEED_URL}\" />" \
" </packageSources>" \
" <packageSourceCredentials>" \
" <GitHubPackages>" \
" <add key=\"Username\" value=\"${VCPKG_FEED_USERNAME}\" />" \
" <add key=\"ClearTextPassword\" value=\"${nuget_auth_token}\" />" \
" </GitHubPackages>" \
" </packageSourceCredentials>" \
" <config>" \
" <add key=\"defaultPushSource\" value=\"GitHubPackages\" />" \
" </config>" \
"</configuration>" \
> "${nuget_config}"; \
export VCPKG_NUGET_API_KEY="${nuget_auth_token}"; \
export VCPKG_BINARY_SOURCES="clear;nugetconfig,${nuget_config},${cache_access};nugettimeout,1200"; \
elif [ -n "${VCPKG_BINARY_SOURCES:-}" ]; then \
echo "Using provided VCPKG_BINARY_SOURCES."; \
else \
unset VCPKG_BINARY_SOURCES; \
fi; \
/opt/vcpkg/vcpkg install \
--x-manifest-root=/opt/vcpkg_manifest \
--x-install-root=/opt/vcpkg_installed \
--triplet=x64-linux \
--host-triplet=x64-linux; \
if [ -n "${nuget_config}" ]; then rm -f "${nuget_config}"; fi'
FROM dependencies AS build
WORKDIR /srv
COPY CMakeLists.txt CMakePresets.json vcpkg.json /srv/
COPY cmake /srv/cmake
COPY src /srv/src
COPY --from=dependencies /opt/vcpkg_installed /srv/vcpkg_installed
RUN export VCPKG_ROOT=/opt/vcpkg \
&& cmake --preset linux-release \
-DTOGGLE_BIN_FOLDER=ON \
-DOPTIONS_ENABLE_IPO=OFF \
-DOTCLIENT_BUILD_TESTS=OFF \
-DBUILD_STATIC_LIBRARY=ON \
-DVCPKG_MANIFEST_INSTALL=OFF \
-DVCPKG_INSTALLED_DIR=/srv/vcpkg_installed \
&& cmake --build --preset linux-release --target otclient
FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
ENV TZ=Etc/UTC
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libgl1 \
libglu1-mesa \
libopenal1 \
libstdc++6 \
libx11-6 \
libxcursor1 \
libxi6 \
libxinerama1 \
libxrandr2 \
tzdata \
&& ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime \
&& echo "${TZ}" > /etc/timezone \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& groupadd --system otclient \
&& useradd --system --create-home --gid otclient --home-dir /home/otclient otclient \
&& install -d -o otclient -g otclient /otclient
WORKDIR /otclient
COPY --from=build --chown=otclient:otclient /srv/build/linux-release/bin/ /otclient/
COPY --chown=otclient:otclient data /otclient/data
COPY --chown=otclient:otclient mods /otclient/mods
COPY --chown=otclient:otclient modules /otclient/modules
COPY --chown=otclient:otclient init.lua otclientrc.lua cacert.pem /otclient/
USER otclient
CMD ["./otclient"]