-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathDockerfile
More file actions
135 lines (116 loc) · 5.13 KB
/
Dockerfile
File metadata and controls
135 lines (116 loc) · 5.13 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
# This builds a "base" image that contains dependencies that are required at
# runtime *and* to install dependencies like `ruby`. Then it builds images that
# intall those dependencies. Then it builds a "final" image that copies the
# dependencies and installs package that it needs at runtime. Compared to
# installing everything in one go this shrinks the "final" docker image by
# about 50%, mostly because we don't need things like `gcc` and `ruby-dev` in
# the "final" image.
# Debian builds the docs about 20% faster than alpine. The image is larger
# and takes longer to build but that is worth it.
FROM bitnami/minideb:buster AS base
RUN echo "deb http://archive.debian.org/debian/ buster main" > /etc/apt/sources.list && \
echo "deb http://archive.debian.org/debian-security/ buster/updates main" >> /etc/apt/sources.list
# TODO install_packages calls apt-get update and then nukes the list files after. We should avoid multiple calls to apt-get update.....
# We could probably fix this by running the update and installs ourself with `RUN --mount type=cache` but that is "experimental"
COPY --chmod=755 .docker/install_packages.sh /usr/local/bin/
# Fix for Debian Buster EOL - point to archive repositories
RUN sed -i 's/deb.debian.org/archive.debian.org/g' /etc/apt/sources.list && \
sed -i 's/security.debian.org/archive.debian.org/g' /etc/apt/sources.list && \
sed -i '/buster-updates/d' /etc/apt/sources.list
RUN install_packages.sh apt-transport-https gnupg2 ca-certificates
COPY .docker/apt/keys/nodesource.gpg /
RUN apt-key add /nodesource.gpg
COPY .docker/apt/sources.list.d/nodesource.list /etc/apt/sources.list.d/
RUN install_packages.sh \
build-essential python2 \
# needed for compiling native modules on ARM
nodejs ruby \
# Used both to install dependencies and at run time
bash less \
# Just in case you have to shell into the image
locales \
# Deal with utf-8 characters properly
dumb-init
# Reap zombie git gc processes
RUN echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
FROM base AS ruby_deps
RUN install_packages.sh \
bundler \
# Fetches ruby dependencies
ruby-dev make cmake gcc libc-dev patch
# Required to compile some of the native dependencies
RUN bundle config --global silence_root_warning 1
COPY Gemfile* /
# --frozen forces us to regenerate Gemfile.lock locally before using it in
# docker which lets us lock the versions in place.
RUN bundle install --binstubs --system --frozen --without test
COPY .docker/asciidoctor_2_0_10.patch /
RUN cd /var/lib/gems/2.5.0/gems/asciidoctor-2.0.10 && patch -p1 < /asciidoctor_2_0_10.patch
FROM base AS node_deps
COPY .docker/apt/keys/yarn.gpg /
RUN apt-key add /yarn.gpg
COPY .docker/apt/sources.list.d/yarn.list /etc/apt/sources.list.d/
RUN install_packages.sh yarn=1.22.19-1
COPY package.json /
COPY yarn.lock /
ENV YARN_CACHE_FOLDER=/tmp/.yarn-cache
# --frozen-lockfile forces us to regenerate yarn.lock locally before using it
# in docker which lets us lock the versions in place.
RUN yarn install --frozen-lockfile --production
# This is the image we use to build the docs. We build on it in other
# Dockerfiles to make the images to serve previews and air gapped docs.
FROM base AS build
LABEL MAINTAINERS="Nik Everett <nik@elastic.co>"
RUN install_packages.sh \
git \
# Clone source repositories and commit to destination repositories
libnss-wrapper \
# Used to clean up user id differences in the docker image.
make \
# Used by the tests
nginx \
# Serves docs during tests and when the container is used for "preview" or
# "air gapped" docs
openssh-client \
# Used by git
openssh-server \
# Used to forward git authentication to the image on OSX
perl-base \
# The "glue" of the docs build is written in perl
libcapture-tiny-perl \
libfile-copy-recursive-perl \
libparallel-forkmanager-perl \
libpath-class-perl \
libxml-libxml-perl \
libyaml-perl
# Perl libraries used by the docs build
COPY --from=node_deps /node_modules /node_modules
COPY --from=ruby_deps /var/lib/gems /var/lib/gems
COPY --from=ruby_deps /usr/local/bin/asciidoctor /usr/local/bin/asciidoctor
# We mount these directories with tmpfs so we can write to them so they
# have to be empty. So we delete them.
RUN rm -rf /var/log/nginx && rm -rf /run/nginx
##### Everything below this run tests
FROM base AS py_test
# There's not a published wheel for yamale, so we need setuptools and wheel
RUN install_packages.sh python3 python3-pip python3-setuptools python3-wheel python3-dev libxml2-dev libxslt-dev zlib1g-dev
RUN pip3 install \
beautifulsoup4==4.8.1 \
lxml==4.4.2 \
pycodestyle==2.5.0 \
yamale==3.0.1 \
pyyaml==5.3.1
FROM node_deps AS node_test
RUN yarn install --frozen-lockfile
FROM ruby_deps AS ruby_test
RUN bundle install --binstubs --system --frozen --with test
FROM build AS integ_test
COPY --from=node_test /node_modules /node_modules
COPY --from=ruby_test /var/lib/gems /var/lib/gems
COPY --from=ruby_test /usr/local/bin/rspec /usr/local/bin/rspec
COPY --from=ruby_test /usr/local/bin/rubocop /usr/local/bin/rubocop
FROM py_test AS diff_tool
RUN install_packages.sh git