-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
80 lines (64 loc) · 3.22 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
78
79
80
# Build api server
FROM --platform=linux/amd64 ubuntu:22.10 as ApiServerBuild
# Install all packages
RUN apt-get update -y && \
apt-get install cmake git curl zip unzip tar build-essential pkg-config make \
libgtk-3-dev libsecret-1-dev libgcrypt20-dev libsystemd-dev \
mesa-utils libglu1-mesa-dev freeglut3-dev mesa-common-dev libgl1-mesa-dev libgles2-mesa-dev -y
# Copy sources into work dir
WORKDIR /Workdir
COPY . .
# Install vcpkg
WORKDIR /vcpkg
RUN git clone https://github.com/Microsoft/vcpkg.git . && \
./bootstrap-vcpkg.sh
# Finally configure and build
WORKDIR /Workdir/BuildResult
RUN export CC=gcc CXX=g++ CMAKE_MAKE_PROGRAM=make && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_BUILD_TYPE=release && \
cmake --build . --target ApiServer --config Release
FROM --platform=linux/amd64 ubuntu:22.10 as ClientBuild
# Install all packages and add additional repos
RUN apt-get update -y && \
apt-get install wget apt-transport-https software-properties-common -y && \
echo "deb http://security.ubuntu.com/ubuntu impish-security main" | tee /etc/apt/sources.list.d/impish-security.list && \
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb && \
dpkg -i packages-microsoft-prod.deb && \
apt-get update -y && \
apt-get install cmake make pkg-config git curl zip unzip tar libssl1.1 powershell \
gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev -y
# Copy sources into work dir
WORKDIR /Workdir
COPY . .
# Install vcpkg
WORKDIR /vcpkg
RUN git clone https://github.com/Microsoft/vcpkg.git . && \
./bootstrap-vcpkg.sh
# TODO: Fix it in some more elegant way?
# Need to create symlinks since some packages can't find win32 headers without first capical letter
RUN ln -s /usr/x86_64-w64-mingw32/include/windows.h /usr/x86_64-w64-mingw32/include/Windows.h && \
ln -s /usr/x86_64-w64-mingw32/include/winsock2.h /usr/x86_64-w64-mingw32/include/WinSock2.h && \
ln -s /usr/x86_64-w64-mingw32/include/rpc.h /usr/x86_64-w64-mingw32/include/Rpc.h && \
# Set compiler symlink to posix since we need to support std threading library
echo '1' | update-alternatives --config x86_64-w64-mingw32-g++ && \
echo '1' | update-alternatives --config x86_64-w64-mingw32-gcc
# Finally run configuration and build
WORKDIR /Workdir/BuildResult
RUN export CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ && \
CMAKE_MAKE_PROGRAM=make RC=x86_64-w64-mingw32-windres && \
cmake .. -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-mingw-static \
-DCMAKE_SYSTEM_NAME=Windows -DVCPKG_BUILD_TYPE=release && \
cmake --build . --target Client --config Release
# Create image which holds built artifacts
FROM --platform=linux/amd64 ubuntu:22.10 as ResultImage
RUN apt-get update -y && \
apt-get install libbrotli1 -y
# Copy all compiled binaries
COPY --from=ApiServerBuild /Workdir/BuildResult/api-server-bin /api-server-bin
COPY --from=ClientBuild /Workdir/BuildResult/client-bin /api-server-bin/client
WORKDIR api-server-bin
# Add metadata to image
VOLUME /api-server-bin/configs
VOLUME /api-server-bin/storage
EXPOSE 7788
ENTRYPOINT ./ApiServer