-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
156 lines (125 loc) · 4.31 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
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
# syntax=docker/dockerfile:1.4
# Build and test images (No need to worry about creating intermediate images)
#
# We use separate stages for running lint and test vs. building the production
# bundle so that they can run in parallel
FROM ubuntu:22.04 AS buildenv
ENV DEBIAN_FRONTEND noninteractive
# Install build deps
RUN <<'EOF'
#!/bin/bash
set -eux
set -o pipefail
apt-get update
# We need:
# * git: for fetching moira and capturing git rev in Meteor artifact
# * curl: for the Meteor installer and fetching new apt keys
# * python3 et al: for building mediasoup
# * comerr-dev et al: for building moira
apt-get install --no-install-recommends -y \
build-essential \
git \
curl \
python3 python3-pip python3-dev python3-setuptools python3-wheel \
comerr-dev libkrb5-dev libreadline-dev libhesiod-dev libncurses5-dev autoconf
# The easiest way to install puppeteer's dependencies is to pull the
# dependencies for Chrome. We don't actually need to install Chrome, but this
# prevents us from needing to manually maintain the list of dependencies here.
curl https://dl-ssl.google.com/linux/linux_signing_key.pub > /etc/apt/trusted.gpg.d/google.asc
echo "deb https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
apt-get update
apt-get satisfy --no-install-recommends -y "$(apt-cache show google-chrome-stable | sed -ne 's/^Depends: //p')"
EOF
FROM buildenv as moiraenv
# Fetch source code
WORKDIR /moira/src
RUN git clone https://github.com/mit-athena/moira .
# Build moira
WORKDIR /moira/src/moira
RUN <<'EOF'
#!/bin/bash
set -eux
set -o pipefail
# Update config.guess and config.sub to support aarch64 (note that in newer
# Ubuntu releases, this has moved to /usr/share/autoconf/build-aux)
cp /usr/share/autoconf/build-aux/config.{guess,sub} .
./configure --with-krb5 --with-com_err --with-afs --with-hesiod --with-readline --without-zephyr --without-java --prefix=/usr
make -j
make install DESTDIR=/moira/build
EOF
FROM buildenv as meteorenv
WORKDIR /app
ARG CI=true
# Install Meteor
COPY .meteor/release /app/.meteor/release
RUN <<'EOF'
#!/bin/bash
set -eux
set -o pipefail
METEOR_RELEASE="$(sed -e 's/.*@//g' .meteor/release)"
curl -sL "https://install.meteor.com?release=$METEOR_RELEASE" | sh
EOF
# Install meteor deps (list is sufficient to do this)
COPY .meteor /app/.meteor
RUN METEOR_ALLOW_SUPERUSER=1 meteor list
# Install app deps
COPY package.json package-lock.json tsconfig.json /app
COPY eslint /app/eslint
RUN --mount=type=cache,target=/root/.npm <<'EOF'
#!/bin/bash
set -eux
set -o pipefail
meteor npm ci
meteor npm run prepare
EOF
COPY . /app
FROM meteorenv AS test
# Run lint
COPY <<'EOF' /test.sh
#!/bin/bash
set -eux
set -o pipefail
export METEOR_ALLOW_SUPERUSER=1
meteor npm run lint | sed -e "s,/app/,${PATH_PREFIX:+${PATH_PREFIX}/},g"
meteor npm run test
EOF
CMD ["/bin/bash", "/test.sh"]
FROM meteorenv AS build
# Generate production build
RUN --mount=type=cache,target=/app/.meteor/local/ meteor build --allow-superuser --directory /built_app --server=http://localhost:3000
# Install server dependencies
WORKDIR /built_app/bundle/programs/server
RUN --mount=type=cache,target=/root/.npm meteor npm install --production --omit=optional
# Production image
# (Be careful about creating as few layers as possible)
FROM ubuntu:22.04 AS production
# Install runtime deps
RUN <<'EOF'
#!/bin/bash
set -eux
set -o pipefail
. /etc/os-release
# Install apt https support for node.
apt-get update
apt-get install --no-install-recommends -y apt-transport-https ca-certificates curl
# Install moira dependencies (use the dev packages to avoid pinning to specific sonames)
apt-get install --no-install-recommends -y comerr-dev libkrb5-dev libreadline-dev libhesiod-dev libncurses5-dev
# Add node apt repo
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key > /etc/apt/trusted.gpg.d/nodesource.asc
echo "deb https://deb.nodesource.com/node_14.x $VERSION_CODENAME main" > /etc/apt/sources.list.d/node.list
apt-get update
apt-get install --no-install-recommends -y awscli nodejs kstart
# Cleanup
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
COPY --from=moiraenv --link /moira/build /
COPY --from=build --link /built_app /built_app
COPY scripts /built_app/scripts
ENV PORT 80
EXPOSE 80
# Mediasoup RTC ports
EXPOSE 10000-59999/udp
EXPOSE 10000-59999/tcp
WORKDIR /built_app/bundle
CMD /built_app/scripts/run_jolly_roger.sh