-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
124 lines (104 loc) · 5.45 KB
/
Copy pathDockerfile
File metadata and controls
124 lines (104 loc) · 5.45 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
FROM composer:2 AS phpredis-source
ARG PHPREDIS_VERSION=6.3.0
ARG PHPREDIS_COMMIT=df4fab2de7fc327c54c94a13af2b9542e4fbd720
RUN git clone --depth 1 --branch "${PHPREDIS_VERSION}" https://github.com/phpredis/phpredis.git /phpredis \
&& cd /phpredis \
&& RESOLVED_COMMIT="$(git rev-parse HEAD)" \
&& if [ "${RESOLVED_COMMIT}" != "${PHPREDIS_COMMIT}" ]; then \
echo "ERROR: Resolved phpredis commit ${RESOLVED_COMMIT} does not match pinned PHPREDIS_COMMIT=${PHPREDIS_COMMIT}" >&2; \
exit 1; \
fi
FROM php:8.3-cli AS base
COPY --from=phpredis-source /phpredis /usr/src/php/ext/redis
RUN apt-get update && apt-get install -y \
curl \
libpq-dev \
libzip-dev \
nodejs \
python3 \
python3-venv \
unzip \
&& docker-php-ext-install redis pdo pdo_mysql pdo_pgsql pcntl zip bcmath \
&& rm -rf /var/lib/apt/lists/*
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app
# ── Dependencies ──────────────────────────────────────────────────────
# Workflow source verification, dependency installation, and the runtime
# filesystem deliberately share this final stage. A named build context
# therefore cannot replace a post-verification /workflow or /app copy.
FROM base AS production
ARG WORKFLOW_PACKAGE_SOURCE=https://github.com/durable-workflow/workflow.git
ARG WORKFLOW_PACKAGE_REF=2.0.0-alpha.279
ARG WORKFLOW_PACKAGE_COMMIT=f9a00e18fa21196bcb3505710489025ff93cf5e1
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/* \
&& if ! printf '%s' "${WORKFLOW_PACKAGE_COMMIT}" | grep -Eq '^[0-9a-f]{40}$'; then \
echo "ERROR: WORKFLOW_PACKAGE_COMMIT must be a full lowercase Git SHA" >&2; \
exit 1; \
fi \
&& git clone --depth 1 --branch "${WORKFLOW_PACKAGE_REF}" "${WORKFLOW_PACKAGE_SOURCE}" /workflow \
&& RESOLVED_COMMIT="$(git -C /workflow rev-parse HEAD)" \
&& if [ "${RESOLVED_COMMIT}" != "${WORKFLOW_PACKAGE_COMMIT}" ]; then \
echo "ERROR: Resolved commit ${RESOLVED_COMMIT} does not match pinned WORKFLOW_PACKAGE_COMMIT=${WORKFLOW_PACKAGE_COMMIT}" >&2; \
exit 1; \
fi \
&& git -C /workflow diff --quiet HEAD -- \
&& printf '%s\n' \
"${WORKFLOW_PACKAGE_SOURCE}" \
"${WORKFLOW_PACKAGE_REF}" \
"${RESOLVED_COMMIT}" \
> /workflow/.package-provenance
COPY composer.json composer.lock ./
COPY scripts/ci/prepare-release-workflow-composer-metadata.php scripts/ci/prepare-release-workflow-composer-metadata.php
RUN php scripts/ci/prepare-release-workflow-composer-metadata.php \
&& composer update durable-workflow/workflow --no-dev --no-scripts --no-autoloader --prefer-dist --no-interaction --no-progress \
&& cp composer.json /tmp/release-composer.json \
&& cp composer.lock /tmp/release-composer.lock \
&& rm -rf /workflow/.git
COPY . .
RUN cp /tmp/release-composer.json composer.json \
&& cp /tmp/release-composer.lock composer.lock \
&& rm -f /tmp/release-composer.json /tmp/release-composer.lock \
&& composer dump-autoload --optimize \
&& cp /workflow/.package-provenance /app/.package-provenance
# ── Production image ─────────────────────────────────────────────────
COPY docker/bootstrap.sh /usr/local/bin/server-bootstrap
COPY docker/ensure-sqlite-database.sh /usr/local/bin/server-ensure-sqlite
COPY docker/entrypoint.sh /usr/local/bin/server-entrypoint
COPY docker/php-custom.ini /usr/local/etc/php/conf.d/99-custom.ini
RUN chmod +x /usr/local/bin/server-bootstrap /usr/local/bin/server-ensure-sqlite /usr/local/bin/server-entrypoint
# Route cache is safe at build time (no env dependency).
# Config cache is deferred to the entrypoint so runtime env vars take effect.
RUN php artisan route:cache \
&& mkdir -p \
storage/logs \
storage/framework/cache/data \
storage/framework/sessions \
storage/framework/views \
storage/framework/testing \
bootstrap/cache \
&& chown -R 1000:1000 storage bootstrap/cache \
&& chmod -R ug+rwX storage bootstrap/cache
LABEL org.opencontainers.image.title="Durable Workflow Server" \
org.opencontainers.image.description="Standalone Durable Workflow server" \
dev.durable-workflow.package.source="${WORKFLOW_PACKAGE_SOURCE}" \
dev.durable-workflow.package.ref="${WORKFLOW_PACKAGE_REF}" \
dev.durable-workflow.package.commit="${WORKFLOW_PACKAGE_COMMIT}"
EXPOSE 8080
# Default to 24 CLI server worker processes so concurrent workflow starts,
# bounded worker polls, and control-plane requests cannot consume every
# request worker ahead of liveness probes. `php artisan serve` only honours
# PHP_CLI_SERVER_WORKERS when `--no-reload` is set (otherwise it warns and
# falls back to a single
# server thread), so both must be present together. The runtime long-poll
# wait gate derives a smaller idle-wait budget from this count and keeps
# the rest for health, workflow start/list, and worker completion traffic.
ENV PHP_CLI_SERVER_WORKERS=24 \
DB_CONNECTION=sqlite \
DB_DATABASE=/app/database/database.sqlite \
QUEUE_CONNECTION=database \
CACHE_STORE=file
ENTRYPOINT ["server-entrypoint"]
# Default: run the API server. Override CMD for workers.
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8080", "--no-reload"]