-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
66 lines (48 loc) · 1.95 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
# docker container build file
# for: Toohga
# created in: 2017 by: Jarne
# Start from Apache HTTP with PHP
FROM php:8.4-apache
# Other dependency versions
ENV NODE_VERSION=20
ENV PECL_REDIS_VERSION=6.0.2
# Run package list updates and install needed services
RUN apt-get update
RUN apt-get install -y wget unzip gnupg
# Add Nodesource GPG key for installing Node.js (client)
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# Run package list updates, install Node.js and enable Corepack for Yarn
RUN apt-get update
RUN apt-get install -y nodejs
RUN corepack enable
# Install MySQLi & Redis extension
RUN docker-php-ext-install mysqli
RUN pecl install redis-${PECL_REDIS_VERSION} && docker-php-ext-enable redis
# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Go into the application folder
WORKDIR /var/www/Toohga
# Gain permissions to the app user for the created source folder
RUN chown www-data:www-data /var/www/Toohga
# Add app source code and set permissions to application user
COPY --chown=www-data:www-data ./ ./
# Install PHP dependecies with Composer
RUN wget https://getcomposer.org/composer.phar
RUN php composer.phar install --no-dev --no-interaction --optimize-autoloader
RUN rm composer.phar
# Switch into front-end subdirectory
WORKDIR /var/www/Toohga/client
# Install client dependecies with Yarn
RUN yarn install --frozen-lockfile
# Build front-end client
RUN yarn run build
# Add the predefined Apache2 config
COPY 000-default.conf /etc/apache2/sites-available/
# Enable Apache2 mods
RUN a2enmod rewrite
# Go into the application folder
WORKDIR /var/www/Toohga
# Run startup commands
CMD ["/bin/sh", "docker-cmd.sh"]