forked from Automattic/wp-calypso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.base
More file actions
150 lines (128 loc) · 4.88 KB
/
Dockerfile.base
File metadata and controls
150 lines (128 loc) · 4.88 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
#### 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:22.9.0-bullseye-slim AS cache
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG node_memory=16384
ARG workers=32
ARG commit_sha="(unknown)"
ARG profile=false
WORKDIR /calypso
ENV NPM_CONFIG_CACHE=/calypso/.cache
ENV PERSISTENT_CACHE=true
ENV GENERATE_CACHE_IMAGE=true
ENV PROFILE=$profile
ENV SKIP_TSC=true
ENV SKIP_CALYPSO_POSTINSTALL=true
ENV SKIP_CALYPSO_PACKAGE_BUILDS=true
ENV CALYPSO_ENV=production
ENV BUILD_TRANSLATION_CHUNKS=true
ENV WORKERS=$workers
ENV NODE_OPTIONS=--max-old-space-size=$node_memory
ENV HOME=/calypso
ENV IS_CI=true
ENV COMMIT_SHA $commit_sha
## If you're testing running on a mac architecture, you may need to add the following
## line to make lzma work:
## RUN apt-get update && apt-get install -y python3 make g++ bzip2 && rm -rf /var/lib/apt/lists/*
COPY . .
## The cache image is only used for /calypso/.cache and /calypso/.yarn, so we can skip downloading browsers.
ENV PLAYWRIGHT_SKIP_DOWNLOAD=true
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
RUN yarn --inline-builds \
&& BUILD_TRANSLATION_CHUNKS=false yarn run build-packages:web \
# Prime the production webpack cache flavors used by PR builds and trunk/Sentry builds.
&& NODE_ENV=production yarn build-client \
&& 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 test and build calypso.
FROM node:22.9.0-bullseye-slim AS base
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ARG node_memory=16384
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 PLAYWRIGHT_SKIP_DOWNLOAD=true
RUN echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/80-retries
# 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 \
# Remove unnecessary packages
&& apt-get autoremove --purge \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* \
# Set bash as the default shell
&& 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
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV PLAYWRIGHT_SKIP_DOWNLOAD=false
ENV DISPLAY=:99
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
# For wp-calypso-test-results dashboard
awscli \
# Install non-Latin fonts
fonts-noto-cjk \
fonts-noto-core \
# Other required packages
git-restore-mtime \
libasound2 \
libatspi2.0-0 \
libdbus-glib-1-2 \
libgtk-3-0 \
libgbm1 \
libnspr4 \
libnss3 \
libsecret-1-0 \
libx11-xcb1 \
libxss1 \
libxtst6 \
openssl \
xauth \
xvfb \
&& apt-get autoremove --purge \
&& apt-get 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
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
COPY --from=cache --chown=$UID /calypso/composer.* /calypso/
RUN apt-get update && \
apt-get install -y apt-transport-https wget
# libffi6 is no longer available from apt as of bullseye.
RUN wget --tries=5 --retry-connrefused --waitretry=2 --timeout=20 --read-timeout=20 \
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 --tries=5 --retry-connrefused --waitretry=2 --timeout=20 --read-timeout=20 \
https://packages.sury.org/php/apt.gpg -O /etc/apt/trusted.gpg.d/php-sury.gpg && \
echo "deb https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php-sury.list && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y php7.4-cli php7.4-xml php7.4-mbstring docker-compose && \
composer install && \
# Install sentry-cli. We pin it to a version to make it easier to know at a
# glance what is the version being used. It's important to keep the JS SDK and
# the CLI updated to their latest stable versions.
wget --tries=5 --retry-connrefused --waitretry=2 --timeout=20 --read-timeout=20 \
-O - https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.18.1" bash
ENTRYPOINT [ "/bin/bash" ]