-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfileProd
More file actions
108 lines (84 loc) · 5.52 KB
/
Copy pathDockerfileProd
File metadata and controls
108 lines (84 loc) · 5.52 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
# -----------------------------------------------------------------------------
# Stage 1: Build frontend assets (Node + PHP for Wayfinder during Vite build)
# -----------------------------------------------------------------------------
FROM ubuntu:24.04 AS assets
ARG NODE_VERSION=24
WORKDIR /app
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99custom && \
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99custom && \
echo "Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99custom
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xb8dc7e53946656efbce4c1dd71daeaab4ad4cab6' | gpg --dearmor -o /etc/apt/keyrings/ppa_ondrej_php.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
php8.5-cli php8.5-mbstring php8.5-xml php8.5-curl php8.5-zip php8.5-bcmath php8.5-intl php8.5-fileinfo php8.5-gd \
nodejs zip \
&& curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY composer.json composer.lock* ./
RUN composer install --no-interaction --no-plugins --no-scripts --prefer-dist
COPY package.json package-lock.json* ./
RUN npm ci --no-audit --no-progress
COPY . .
RUN mkdir -p storage/framework/views storage/framework/cache/data storage/logs bootstrap/cache public/images public/extension
RUN cp .env.example .env && php artisan key:generate --no-interaction
RUN php artisan wayfinder:generate --with-form --no-interaction
RUN npm run build
RUN node scripts/build-extension.mjs
# -----------------------------------------------------------------------------
# Stage 2: Production PHP image
# -----------------------------------------------------------------------------
FROM ubuntu:24.04 AS production
LABEL maintainer="AutoCVApply"
ARG WWWGROUP=1000
ARG WWWUSER=1337
ARG POSTGRES_VERSION=18
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
ENV SUPERVISOR_PHP_USER="sail"
ENV WWWUSER=${WWWUSER}
ENV WWWGROUP=${WWWGROUP}
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99custom && \
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99custom && \
echo "Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99custom
RUN apt-get update && apt-get upgrade -y \
&& mkdir -p /etc/apt/keyrings \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor libcap2-bin libpng-dev dnsutils \
&& curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xb8dc7e53946656efbce4c1dd71daeaab4ad4cab6' | gpg --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \
&& echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/dev/null \
&& echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y \
php8.5-cli php8.5-fpm php8.5-pgsql php8.5-sqlite3 php8.5-gd \
php8.5-curl php8.5-mbstring php8.5-xml php8.5-zip php8.5-bcmath \
php8.5-tokenizer php8.5-fileinfo php8.5-intl php8.5-redis \
nginx \
tesseract-ocr tesseract-ocr-eng poppler-utils \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer
RUN groupadd --force -g $WWWGROUP sail && \
useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u $WWWUSER sail
COPY --from=assets /app/vendor ./vendor
COPY --from=assets /app/public/build ./public/build
COPY --from=assets /app/public/extension ./public/extension
COPY . .
RUN mkdir -p storage/framework/{views,cache/data,sessions} storage/logs bootstrap/cache public/images
# Static brand assets - copied last so deploy cache cannot serve stale favicons
ARG GIT_SHA=dev
RUN echo "AutoCVApply image built from ${GIT_SHA}"
COPY public/favicon.ico public/favicon.svg public/apple-touch-icon.png ./public/
COPY docker/production/nginx.conf /etc/nginx/nginx.conf
COPY docker/production/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/production/www-pool.conf /etc/php/8.5/fpm/pool.d/www.conf
RUN chmod +x /var/www/html/docker/production/start.sh 2>/dev/null || true
EXPOSE 80
ENTRYPOINT ["bash", "-c", "chown -R sail:sail /var/www/html/storage /var/www/html/bootstrap/cache && ln -sfn /var/www/html/storage/app/public /var/www/html/public/storage && gosu sail php artisan config:cache && gosu sail php artisan route:cache && gosu sail php artisan view:cache && /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf"]