-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (60 loc) · 2.93 KB
/
Copy pathDockerfile
File metadata and controls
74 lines (60 loc) · 2.93 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
# Use the official PHP 8.4 CLI image as the base image
FROM php:8.4-cli AS build
# Install necessary PHP extensions and Composer in one step to minimize layers
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
apt-get update -y && \
apt-get install -y --no-install-suggests --no-install-recommends \
libicu-dev libonig-dev libzip-dev libpq-dev gettext libyaml-dev && \
docker-php-ext-install intl zip calendar gettext pdo pdo_pgsql && \
pecl install apcu yaml redis-6.3.0 && \
docker-php-ext-enable intl zip calendar apcu yaml gettext redis && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /var/www/html
# Copy composer files first for caching purposes
COPY composer.json composer.lock ./
# Run composer install to install dependencies
RUN --mount=type=cache,target=/tmp/composer \
composer install --no-interaction --prefer-dist \
--optimize-autoloader --no-dev
# Copy the rest of the application code (.dockerignore not working when building from docker compose and remote repo)
COPY ./src ./src
COPY ./i18n ./i18n
COPY ./jsondata ./jsondata
COPY ./public/LitCalTestServer.php ./public/index.php ./public/
COPY ./.env.example ./.env.local
# Include scripts directory (setup scripts, init-db.sql, openfga model)
# so consumers (e.g., frontend docker-compose) can extract them.
COPY ./scripts ./scripts
# Include the Doctrine migrations CLI script + its config so the
# docker-compose `litcal-migrate` one-shot service can invoke
# `php bin/doctrine-migrations migrate --no-interaction`. Both files
# are tiny (the CLI bootstraps DependencyFactory from env vars; the
# config declares table_storage + migrations_paths).
COPY ./bin ./bin
COPY ./doctrine-migrations.php ./
# Stage 2: final build
FROM php:8.4-cli AS main
# Set the working directory
WORKDIR /var/www/html
# Install runtime dependencies (not the -dev packages).
# jq is included so consumers of this image (e.g., the frontend's openfga-setup
# service) can run setup-openfga.sh / setup-zitadel.sh without an apt-get install
# at container start. curl is already provided by the php:8.4-cli base image.
RUN apt-get update -y && \
apt-get install -y --no-install-suggests --no-install-recommends \
libyaml-0-2 libicu76 libzip5 libpq5 locales-all jq && \
rm -rf /var/lib/apt/lists/*
# Copy the compiled PHP extensions from the build stage
COPY --from=build /usr/local/lib/php/extensions /usr/local/lib/php/extensions
COPY --from=build /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
COPY --from=build /usr/local/bin/composer /usr/local/bin/composer
COPY --from=build /var/www/html /var/www/html
# Set the environment variable
ENV PHP_CLI_SERVER_WORKERS=6
# Expose port 8000 to the host
EXPOSE 8000
# Command to run PHP's built-in server
CMD ["php", "-S", "0.0.0.0:8000", "-t", "/var/www/html/public"]