-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
80 lines (69 loc) · 1.6 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
ARG VARIANT=8-apache
FROM php:${VARIANT}
# Prepare user
ARG PUID=1000
ARG PGID=1000
RUN \
groupadd -g ${PGID} cartridge && \
useradd -u ${PUID} -g ${PGID} cartridge
# Install packages
RUN \
echo "🌐 Installing dependencies" && \
apt-get update && \
apt-get install -y --no-install-recommends \
git \
cron \
unzip \
nodejs \
npm \
zip && \
echo "🧹 Cleaning up" && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*
# Enable Apache modules
RUN \
a2enmod rewrite
# Add Apache conf
COPY apache.conf /etc/apache2/sites-available/000-default.conf
# Install PHP extensions
RUN \
docker-php-ext-install \
mysqli \
pdo \
pdo_mysql
# Prepare workdir
RUN mkdir -p /var/www/cartridge && chown cartridge:cartridge /var/www/cartridge
WORKDIR /var/www/cartridge
COPY --chown=cartridge:cartridge . .
# Get latest Composer
ARG COMPOSER_VERSION=latest
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
RUN \
echo "🎵 Installing Composer packages" && \
composer install && \
echo "🧹 Cleaning up" && \
composer clearcache
# Node
RUN \
echo "💿 Installing Node packages" && \
npm install && \
npm run build && \
echo "🧹 Cleaning up" && \
rm -rf node_modules
# Install scheduler to cron
RUN \
echo "⏳ Installing scheduler" && \
CRONFILE=/etc/cron.d/scheduler && \
mkdir -p /etc/cron.d && \
touch $CRONFILE && \
echo "* * * * * cd ${PWD} && php artisan schedule:run" >> $CRONFILE && \
chmod 0644 $CRONFILE && \
crontab $CRONFILE
# Expose stuff
USER cartridge
VOLUME /games
VOLUME /var/www/cartridge/storage
EXPOSE 80
CMD ["apache2-foreground"]