-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (70 loc) · 2.5 KB
/
Dockerfile
File metadata and controls
88 lines (70 loc) · 2.5 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
FROM node:latest AS node
FROM composer:latest AS composer
FROM php:8.4.15-apache-trixie
# Set custom UID/GID for www-data to match host user (for mounted volumes)
ENV UID=1000
ENV GID=1000
# Install dependencies
RUN apt-get update && apt-get install -y \
openssl \
wget \
git \
unzip \
libzip-dev \
&& docker-php-ext-install zip pdo_mysql \
&& rm -rf /var/lib/apt/lists/*
# Install pnpm
RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh -
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
# Copy Node.js and npm from node stage
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/bin/npm /usr/local/bin/npm
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
# Copy composer from composer stage
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Enable Apache modules for SSL
RUN a2enmod ssl rewrite headers
# Generate self-signed certificate for development
RUN mkdir -p /etc/apache2/certs && \
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/apache2/certs/apache-selfsigned.key \
-out /etc/apache2/certs/apache-selfsigned.crt \
-subj "/C=FR/L=Development/O=Development/CN=localhost"
RUN cat <<CONF >/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
<Directory /var/www/html/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
SSLEngine on
SSLCertificateFile /etc/apache2/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/apache2/certs/apache-selfsigned.key
<Directory /var/www/html/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
CONF
RUN usermod -u ${UID} www-data && \
groupmod -g ${GID} www-data && \
chown -R www-data:www-data /var/www/html
WORKDIR /var/www/html
EXPOSE 443 5173