generated from KennethTrecy/web_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
166 lines (127 loc) · 4.66 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Inspired from Dockerfile made by Kenneth Trecy Tobias for Kotovaulo server (variant A)
# Adapted by Kenneth Trecy Tobias for Peratorakka server
# Other links that influenced this file:
# - `initial_influence`. https://dev.to/veevidify/docker-compose-up-your-entire-laravel-apache-mysql-development-environment-45ea
# - `libonig-dev`. https://www.limstash.com/en/articles/202002/1539
FROM php:8.2-apache AS base
# 1. Install necessary packages.
RUN apt-get update && apt-get install -y \
curl \
g++ \
git \
libfreetype6-dev \
libmcrypt-dev \
sudo \
unzip \
zip
# 2. Apache configs + document root.
# RUN echo 'Header set Access-Control-Allow-Origin "*"' >> /etc/apache2/apache2.conf
RUN sed -ri -e 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# 3. mod_rewrite for URL rewrite and mod_headers for .htaccess extra headers like Access-Control-Allow-Origin-
RUN a2enmod rewrite headers
# 4. Copy base PHP config from development.
RUN cp "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
# 5. Add PHP extensions.
RUN docker-php-ext-install bcmath
RUN sudo apt-get update
RUN apt-get install -y libbz2-dev
RUN docker-php-ext-install bz2
RUN docker-php-ext-install calendar
# RUN docker-php-ext-install ctype
# RUN docker-php-ext-install curl
# RUN docker-php-ext-install dba
# RUN docker-php-ext-install dl_test
# RUN docker-php-ext-install dom
# RUN docker-php-ext-install enchant
# RUN docker-php-ext-install exif
# RUN docker-php-ext-install ffi
# RUN docker-php-ext-install fileinfo
# RUN docker-php-ext-install filter
# RUN docker-php-ext-install ftp
RUN sudo apt-get update
RUN apt-get install -y libjpeg-dev libpng-dev
RUN docker-php-ext-install gd
# RUN docker-php-ext-install gettext
# RUN docker-php-ext-install gmp
# RUN docker-php-ext-install hash
RUN docker-php-ext-install iconv
# RUN docker-php-ext-install imap
RUN sudo apt-get update
RUN apt-get install -y libicu-dev
RUN docker-php-ext-install intl
# RUN docker-php-ext-install json
# RUN docker-php-ext-install ldap
RUN sudo apt-get update
RUN apt-get install -y libonig-dev
RUN docker-php-ext-install mbstring
# RUN docker-php-ext-install mysqli
# RUN docker-php-ext-install oci8
# RUN docker-php-ext-install odbc
RUN docker-php-ext-install opcache
# RUN docker-php-ext-install pcntl
# RUN docker-php-ext-install pdo
# RUN docker-php-ext-install pdo_dblib
# RUN docker-php-ext-install pdo_firebird
# RUN docker-php-ext-install pdo_mysql
# RUN docker-php-ext-install pdo_oci
# RUN docker-php-ext-install pdo_odbc
RUN sudo apt-get update
RUN apt-get install -y libpq-dev
RUN docker-php-ext-install pdo_pgsql
# RUN docker-php-ext-install pdo_sqlite
RUN docker-php-ext-install pgsql
# RUN docker-php-ext-install phar
# RUN docker-php-ext-install posix
# RUN docker-php-ext-install pspell
# RUN docker-php-ext-install random
# RUN sudo apt-get update
# RUN apt-get install -y libedit-dev libedit2 libreadline-dev
# RUN docker-php-ext-install readline # errors here
# RUN docker-php-ext-install reflection
# RUN docker-php-ext-install session
# RUN docker-php-ext-install shmop
# RUN docker-php-ext-install simplexml
# RUN docker-php-ext-install snmp
# RUN docker-php-ext-install soap
# RUN docker-php-ext-install sockets
# RUN docker-php-ext-install sodium
# RUN docker-php-ext-install spl
# RUN docker-php-ext-install standard
# RUN docker-php-ext-install sysvmsg
# RUN docker-php-ext-install sysvsem
# RUN docker-php-ext-install sysvshm
# RUN docker-php-ext-install tidy
# RUN docker-php-ext-install tokenizer
# RUN docker-php-ext-install xml
# RUN docker-php-ext-install xmlreader
# RUN docker-php-ext-install xmlwriter
# RUN docker-php-ext-install xsl
# RUN docker-php-ext-install zend_test
RUN sudo apt-get update
RUN apt-get install -y libzip-dev
RUN docker-php-ext-install zip
# 6. Clear APT cache.
RUN rm -rf /var/lib/apt/lists/*
# 7. Install composer.
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
##########
FROM base as development
##########
FROM base as production
# 1. Copy base PHP config from production.
RUN rm "$PHP_INI_DIR/php.ini-development"
RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# 2. Copy all configuration files
COPY . /var/www/html/
RUN sudo chmod -R a+rw /var/www/html
# 3. Install dependencies
RUN /usr/bin/composer install
# 4. Reconfigure permissions for new directories after installation
RUN sudo chmod -R a+rw /var/www/html/vendor
# 5. Migrate all tables
RUN /usr/bin/composer run seed:initial
# 6. Start HTTP service to apply changes
RUN service apache2 stop
CMD [ "php", "spark", "serve", "--host", "0.0.0.0", "--port", "80" ]
EXPOSE 80