-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.new
67 lines (47 loc) · 1.59 KB
/
Dockerfile.new
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
# Using the LTS version of Node.js ~45MB
FROM node:20.11.1-alpine3.18 AS install-and-build
# Environment variables
WORKDIR /app
ENV NODE_ENV=production
# Build assets (context needed, that is why we don't copy package.json and package-lock.json alone)
COPY . .
COPY .env.docker.example .env
RUN npm install --frozen-lockfile --production --include=dev
RUN npm run build --optimize
FROM trafex/php-nginx:3.4.0
# Install composer from the official image
COPY --from=composer /usr/bin/composer /usr/bin/composer
# USER nginx
WORKDIR /app
COPY --from=install-and-build --chown=nobody /app .
# Install necessary PHP extensions
USER root
RUN apk update && \
apk add --no-cache php82-iconv php82-pdo_pgsql
# Clear Composer cache
RUN composer clear-cache
# Run composer install to install the dependencies - ignore-platform required to *actually* exclude dev deps
RUN composer install --optimize-autoloader --no-interaction --no-dev --ignore-platform-req=ext-simplexml
# Optimizing Configuration loading
RUN php artisan config:cache
# Optimizing Event loading
RUN php artisan event:cache
# Optimizing Route loading
RUN php artisan route:cache
# Optimizing View loading
RUN php artisan view:cache
RUN php artisan optimize
RUN chown -R nobody:nobody /var/www
USER nobody
RUN <<EOF
rm -rf /var/www/html
ln -s /app/public/ /var/www/html
ln -s /var/www/html /var/www/public
ln -s /app/bootstrap /var/www
ln -s /app/vendor /var/www
ln -s /app/app /var/www
ln -s /app/routes /var/www
ln -s /var/www/vendor/livewire/livewire/dist/ /var/www/html/livewire
EOF
COPY ./docker/entrypoint.sh .
ENTRYPOINT [ "/app/entrypoint.sh" ]