forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.base
127 lines (107 loc) · 3.5 KB
/
Dockerfile.base
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
#### cache image
#### This image is not pushed to any repository and it shouldn't be used as base image for any other docker build.
#### Its main goal is to create a `/calypso/.cache` that can be copied over other images that can benefit from a warm cache.
#### Note that yarn v3 cache lives in `/calypso/.yarn`
FROM node:16.17.0-bullseye-slim as cache
ARG node_memory=8192
WORKDIR /calypso
ENV NPM_CONFIG_CACHE=/calypso/.cache
ENV PERSISTENT_CACHE=true
ENV READONLY_CACHE=false
ENV PROFILE=true
ENV SKIP_TSC=true
ENV CALYPSO_ENV=production
ENV BUILD_TRANSLATION_CHUNKS=true
ENV NODE_OPTIONS=--max-old-space-size=$node_memory
ENV HOME=/calypso
COPY . .
RUN yarn \
# Prime webpack caches, including sourcemaps.
&& NODE_ENV=production SOURCEMAP=hidden-source-map yarn build-client
ENTRYPOINT [ "/bin/bash" ]
#### base image
#### This image can be used as a base image for other builds, or to uni test and build calypso.
FROM node:16.17.0-bullseye-slim as base
ARG node_memory=8192
ARG user=calypso
ARG UID=1003
WORKDIR /calypso
ENV NPM_CONFIG_CACHE=/calypso/.cache
ENV NODE_OPTIONS=--max-old-space-size=$node_memory
ENV HOME=/calypso
ENV SKIP_TSC=true
ENV PUPPETEER_SKIP_DOWNLOAD=true
ENV PLAYWRIGHT_SKIP_DOWNLOAD=true
# Add user calypso with uid 1003, give it sudo permissions
RUN apt-get update \
&& apt-get install -y sudo zip jq curl git \
&& adduser --uid $UID --disabled-password $user \
&& echo "$user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$user \
&& chmod 0440 /etc/sudoers.d/$user \
&& chown $UID /calypso \
&& rm -rf /var/lib/apt/lists/* \
&& apt autoremove --purge \
&& apt autoclean
# Set bash as the default shell
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Copy all other caches (webpack, babel, yarn...)
COPY --from=cache --chown=$UID /calypso/.cache /calypso/.cache
COPY --from=cache --chown=$UID /calypso/.yarn /calypso/.yarn
ENTRYPOINT [ "/bin/bash" ]
#### ci-e2e image
#### This image is used to run E2E tests.
FROM base as ci-e2e
ENV PUPPETEER_SKIP_DOWNLOAD=false
ENV PLAYWRIGHT_SKIP_DOWNLOAD=false
ENV DISPLAY=:99
RUN apt update \
&& apt install -y --no-install-recommends \
fonts-liberation \
fonts-noto \
git-restore-mtime \
gtk2-engines-pixbuf \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatspi2.0-0 \
libdbus-glib-1-2 \
libgtk-3-0 \
libgbm-dev \
libnspr4 \
libnss3 \
libsecret-1-dev \
libx11-xcb1 \
libxss1 \
libxtst6 \
openssl \
xauth \
xdg-utils \
xfonts-100dpi \
xfonts-75dpi \
xfonts-base \
xfonts-cyrillic \
xfonts-scalable \
xvfb \
&& apt autoremove --purge \
&& apt autoclean \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "/bin/bash" ]
#### ci-wpcom image
#### This image is used to test and build WPCOM plugins in Calypso repo.
FROM base as ci-wpcom
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
COPY --from=cache --chown=$UID /calypso/composer.* /calypso/
RUN apt update && \
apt install -y apt-transport-https wget
# libffi6 is no longer available from apt as of bullseye.
RUN wget http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/libffi6_3.2.1-8_amd64.deb && \
dpkg -i libffi6_3.2.1-8_amd64.deb && \
wget https://packages.sury.org/php/apt.gpg -O /etc/apt/trusted.gpg.d/php-sury.gpg && \
echo "deb https://packages.sury.org/php/ buster main" > /etc/apt/sources.list.d/php-sury.list && \
apt update && \
apt upgrade -y && \
apt install -y php7.4-cli php7.4-xml php7.4-mbstring docker-compose && \
composer install
# Install sentry-cli.
RUN wget -O - https://sentry.io/get-cli/ | bash
ENTRYPOINT [ "/bin/bash" ]