-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
163 lines (123 loc) · 4.54 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
157
158
159
160
161
162
163
# syntax=docker/dockerfile:1.6
FROM composer:2.8.5 AS composer-base-image
FROM node:23.4.0 AS npm-base-image
FROM ubuntu:22.04 AS ubuntu-base-image
FROM npm-base-image AS npm-dependencies
WORKDIR /build
RUN \
--mount=type=cache,target=/root/.npm,id=npm \
--mount=source=package.json,target=package.json \
--mount=source=package-lock.json,target=package-lock.json \
npm ci
FROM ubuntu-base-image AS base-with-dependencies
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt/lists/,sharing=private \
export DEBIAN_FRONTEND="noninteractive" \
&& rm /etc/apt/apt.conf.d/docker-clean \
&& mkdir -p /usr/share/man/man1 \
&& apt-get update \
&& apt-get -y upgrade \
&& apt-get install -y --no-install-recommends software-properties-common gnupg curl \
&& add-apt-repository --yes ppa:ondrej/php \
&& curl -sL https://deb.nodesource.com/setup_21.x | bash - \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
binutils \
graphviz \
php8.3-bcmath \
php8.3-cli \
php8.3-intl \
php8.3-zip \
php8.3-mbstring \
php8.3-xml \
php8.3-curl \
php8.3-gd \
nodejs \
openjdk-21-jre \
xfonts-75dpi \
xfonts-base \
fontconfig \
libjpeg-turbo8 \
wkhtmltopdf \
&& mkdir -p /docs-package/pdf /app /docs-src/book /docs-src/templates /docs-src/features
ADD https://github.com/plantuml/plantuml/releases/download/v1.2025.0/plantuml-1.2025.0.jar app/bin/plantuml.jar
ENV XDG_RUNTIME_DIR=/tmp/runtime-root
FROM base-with-dependencies AS production-composer-dependencies
WORKDIR /build
RUN \
--mount=source=/usr/bin/composer,target=/usr/bin/composer,from=composer-base-image \
--mount=type=cache,target=/root/.composer,id=composer \
--mount=source=composer.json,target=composer.json \
--mount=source=composer.lock,target=composer.lock \
composer install \
--no-autoloader \
--no-dev \
--no-plugins
FROM production-composer-dependencies AS development-composer-dependencies
WORKDIR /build
RUN \
--mount=source=/usr/bin/composer,target=/usr/bin/composer,from=composer-base-image \
--mount=type=cache,target=/root/.composer,id=composer \
--mount=source=composer.json,target=composer.json \
--mount=source=composer.lock,target=composer.lock \
composer install \
--no-plugins
FROM base-with-dependencies AS base-with-codebase
WORKDIR /app
COPY --link ./src ./src
COPY --link ./bin ./bin
COPY --link --from=npm-dependencies /build/node_modules node_modules
RUN ln -s /app/node_modules/.bin/marked /usr/local/bin/marked \
&& marked --version \
&& ln -s /app/node_modules/.bin/redoc-cli /usr/local/bin/redoc-cli \
&& redoc-cli --version
ENV DOCBOOK_TOOL_CONTENT_PATH=/docs-src/book \
DOCBOOK_TOOL_TEMPLATE_PATH=/docs-src/templates \
DOCBOOK_TOOL_FEATURES_PATH=/docs-src/features \
DOCBOOK_TOOL_OUTPUT_HTML_FILE=/docs-package/index.html \
DOCBOOK_TOOL_OUTPUT_PDF_PATH=/docs-package/pdf
ENTRYPOINT ["bin/docbook-tool"]
CMD ["--html", "--pdf"]
FROM base-with-codebase AS development
COPY --link ./phpcs.xml.dist \
./phpunit.xml.dist \
./psalm.xml.dist \
./
COPY --link ./test test
COPY --link ./composer.json \
./composer.lock \
./package.json \
./package-lock.json \
./
COPY --link --from=composer-base-image /usr/bin/composer /usr/local/bin/composer
COPY --link --from=development-composer-dependencies /build/vendor vendor
# run the plugins
RUN \
--mount=type=cache,target=/root/.composer,id=composer \
composer install
FROM development AS test-output-builder
COPY --link ./test/fixture/templates /docs-src/templates
COPY --link ./test/fixture/docbook /docs-src/book
COPY --link ./test/fixture/feature /docs-src/features
RUN bin/docbook-tool --html --pdf
FROM scratch AS test-output
COPY --from=test-output-builder /docs-package /
FROM development AS tested
RUN vendor/bin/phpunit
RUN vendor/bin/phpcs
RUN vendor/bin/psalm
RUN touch .tested
FROM base-with-codebase AS production
COPY --link --from=production-composer-dependencies /build/vendor vendor
RUN \
--mount=source=/usr/bin/composer,target=/usr/bin/composer,from=composer-base-image \
--mount=type=cache,target=/root/.composer,id=composer \
--mount=source=composer.json,target=composer.json \
--mount=source=composer.lock,target=composer.lock \
composer dump-autoload \
--classmap-authoritative \
--no-dev
# The tests must have run to build production
COPY --link --from=tested /app/.tested .