forked from voidstarHQ/voidstar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
121 lines (110 loc) · 3.9 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
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
# syntax=docker.io/docker/dockerfile:1@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM --platform=$BUILDPLATFORM docker.io/whilp/buildifier@sha256:67da91fdddd40e9947153bc9157ab9103c141fcabcdbf646f040ba7a763bc531 AS buildifier
FROM --platform=$BUILDPLATFORM docker.io/library/ubuntu:20.04@sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322 AS ubuntu
FROM ubuntu AS base
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
RUN \
set -ux \
# https://github.com/moby/buildkit/blob/df49b648c8bfef657ba99543390516a3f518d22a/frontend/dockerfile/docs/syntax.md#example-cache-apt-packages
&& rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
RUN \
--mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
set -ux \
&& apt update \
&& apt install -y --no-install-recommends \
build-essential \
ca-certificates \
clang \
curl \
ffmpeg \
git \
gzip \
libgl1-mesa-dev \
python3 \
software-properties-common \
tar \
unzip \
xauth \
xorg-dev \
xvfb \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1
RUN \
--mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
set -ux \
&& add-apt-repository -y ppa:openjdk-r/ppa \
&& apt update \
&& apt install -y --no-install-recommends \
openjdk-8-jdk
COPY .bazelversion .
RUN \
--mount=type=cache,target=/root/.cache/bazel \
set -ux \
&& mkdir /bazel \
&& curl -fsSLo /bazel/installer.sh "https://github.com/bazelbuild/bazel/releases/download/$(cat .bazelversion)/bazel-$(cat .bazelversion)-installer-linux-x86_64.sh" \
&& chmod +x /bazel/installer.sh \
&& /bazel/installer.sh \
&& rm /bazel/installer.sh
COPY . .
# sync
FROM base AS sync-then-fmt
RUN \
--mount=type=cache,target=/root/.cache/bazel \
set -ux \
&& bazel sync \
&& grep -v -F \"definition_information\": resolved.bzl >resolved.bzl~ \
&& mv resolved.bzl~ resolved.bzl
RUN \
# Ideally we'd be executing buildifier from within the context of its
# container but it turns out to need a shell:
#17 [sync-fmt 2/2] RUN --mount=from=sync-nofmt,source=/app/resolved.bzl,target=/resolved.bzl,readwrite /buildifier -lint=fix /resolved.bzl
#17 0.441 container_linux.go:367: starting container process caused: exec: "/bin/sh": stat /bin/sh: no such file or directory
#17 ERROR: executor failed running [/bin/sh -c /buildifier -lint=fix /resolved.bzl]: exit code: 1
--mount=from=buildifier,source=/buildifier,target=/buildifier \
set -ux \
&& /buildifier -lint=fix resolved.bzl
FROM scratch AS sync
COPY --from=sync-then-fmt /app/resolved.bzl /
# voidstar Clang
FROM base AS builder-clang
RUN \
--mount=type=cache,target=/root/.cache/bazel \
set -ux \
&& bazel build voidstar --repo_env=CC=clang \
&& strip /app/bazel-bin/voidstar/voidstar \
# Necessary as COPY --from does not follow symlinks
&& cp /app/bazel-bin/voidstar/voidstar /
# voidstar GCC
FROM base AS builder-gcc
RUN \
--mount=type=cache,target=/root/.cache/bazel \
set -ux \
&& bazel build voidstar \
&& strip /app/bazel-bin/voidstar/voidstar \
# Necessary as COPY --from does not follow symlinks
&& cp /app/bazel-bin/voidstar/voidstar /
# xvfb GCC
FROM builder-gcc AS xvfb-gcc
ARG WxHxD=800x600x24
ARG BIN=/voidstar
ARG FILE=./data/BigPictureBG.tga
ARG OUT=mp4
RUN ./xvfb.sh
FROM scratch AS video-gcc
COPY --from=xvfb-gcc /app/video.* /
# xvfb Clang
FROM builder-clang AS xvfb-clang
ARG WxHxD=800x600x24
ARG BIN=/voidstar
ARG FILE=./data/BigPictureBG.tga
ARG OUT=mp4
RUN ./xvfb.sh
FROM scratch AS video-clang
COPY --from=xvfb-clang /app/video.* /
FROM scratch AS voidstar-clang
COPY --from=builder-clang /voidstar /
FROM scratch AS voidstar
COPY --from=builder-gcc /voidstar /