-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
86 lines (64 loc) · 2.47 KB
/
Dockerfile
File metadata and controls
86 lines (64 loc) · 2.47 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
# Multi-stage build for Vue.js frontend + PHP backend
FROM node:25-alpine AS frontend-builder
# Build Vue.js frontend
WORKDIR /app/client
# Update npm to latest version
RUN npm install -g npm@latest
COPY client/package*.json ./
RUN npm install
COPY client/ ./
RUN npm run build
# PHP + Nginx container
FROM trafex/php-nginx:3.11.1
# Switch to root for installation
USER root
# Install additional packages needed for your application
RUN apk add --no-cache \
git \
unzip \
ffmpeg \
mediainfo \
postgresql-client \
php85-zip \
php85-pgsql \
php85-pdo_pgsql \
php85-simplexml \
php85-xmlwriter \
php85-xmlreader \
php85-fileinfo
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Copy the server code into the container
COPY server/ ./
# Copy built Vue.js frontend from the first stage
COPY --from=frontend-builder /app/client/dist/ ./public/
# Copy config sample to config directory
COPY server/src/config_sample.php ./var/config/config.php
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Make scheduler executable
RUN chmod +x ./scripts/scheduler.sh
# Add scheduler as supervised process
RUN echo -e '[program:scheduler]\ncommand=/var/www/html/scripts/scheduler.sh\nautostart=true\nautorestart=true\nstdout_logfile=/dev/stdout\nstdout_logfile_maxbytes=0\nstderr_logfile=/dev/stderr\nstderr_logfile_maxbytes=0\nuser=nobody' > /etc/supervisor/conf.d/scheduler.conf
# Create necessary directories and set permissions
RUN mkdir -p /var/www/.composer \
&& mkdir -p ./var/cache ./var/img ./var/logs ./var/music \
&& chown -R nobody:nobody /var/www
# Configure Nginx for SPA
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Switch to the nobody user to run Composer install and clear cache
USER nobody
RUN composer install --no-interaction --prefer-dist --optimize-autoloader && \
composer clear-cache
# Switch back to root to remove composer and clean up
USER root
RUN rm -f /usr/bin/composer && rm -rf /var/www/.composer
# Switch back to nobody for running the container
USER nobody
# Declare persistent volume directories
VOLUME ["/var/www/html/config", "/var/www/html/var/cache", "/var/www/html/var/img", "/var/www/html/var/logs", "/var/www/html/var/music"]
# Use custom entrypoint that runs migrations before starting the app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]