-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
98 lines (60 loc) · 2.44 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
# Frontend builder
FROM node:16-slim as frontend
RUN npm config set registry https://registry.npmmirror.com/ && \
npm install -g pnpm@^8
WORKDIR /app/react
# Files required by pnpm install
COPY react/package.json react/pnpm-lock.yaml ./
RUN pnpm config set registry https://registry.npmmirror.com/ && \
pnpm install --frozen-lockfile
COPY react/ .
RUN mkdir /app/public
ARG COMMIT_HASH
ARG VITE_SENTRY_DSN
ENV COMMIT_HASH=${COMMIT_HASH:-"unknown"}
ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN
RUN pnpm build
# Backend dependency builder for production
FROM php:8.2-apache as build
RUN sed -i s/deb.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list && \
sed -i s/security.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list && \
apt-get update
# Required for composer
RUN apt-get install -y --no-install-recommends git unzip
WORKDIR /app
COPY . .
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction
# Backend dependency builder for development
FROM php:8.2-apache as build-dev
RUN sed -i s/deb.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list && \
sed -i s/security.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list && \
apt-get update
# Required for composer
RUN apt-get install -y --no-install-recommends git unzip
WORKDIR /app
COPY . .
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN composer install --prefer-dist --no-interaction
# Application builder for development
FROM php:8.2-apache as dev
RUN docker-php-ext-install bcmath pdo_mysql
WORKDIR /var/www/html
COPY --from=frontend /app/public ./public
COPY --from=build-dev --chown=www-data:www-data ./app .
COPY docker/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite && \
mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
bash ./docker/configure.sh
# Application builder for production
FROM php:8.2-apache as production
RUN docker-php-ext-install bcmath pdo_mysql
WORKDIR /var/www/html
COPY --from=frontend /app/public ./public
COPY --from=build --chown=www-data:www-data /app .
COPY docker/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \
bash ./docker/configure.sh
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost/ || exit 1