forked from smrealms/smr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
63 lines (46 loc) · 1.96 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
FROM node:alpine as builder
WORKDIR /smr/
# See https://github.com/hollandben/grunt-cache-bust/issues/236
RUN npm i --save grunt grunt-contrib-uglify grunt-contrib-cssmin [email protected]
# Copy the SMR source code directories
COPY admin admin
COPY engine engine
COPY htdocs htdocs
COPY lib lib
COPY templates templates
# Perform CSS/JS minification and cache busting
COPY Gruntfile.js .
RUN npx grunt
# Remove local grunt install so it is not copied to the next build stage
RUN rm -rf node_modules
#---------------------------
FROM php:7.3-apache
RUN apt-get update \
&& apt-get install -y zip unzip \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-install mysqli opcache
# Disable apache access logging (error logging is still enabled)
RUN sed -i 's|CustomLog.*|CustomLog /dev/null common|' /etc/apache2/sites-enabled/000-default.conf
# Disable apache .htaccess files (suggested optimization)
RUN sed -i 's/AllowOverride All/AllowOverride None/g' /etc/apache2/conf-enabled/docker-php.conf
WORKDIR /smr/
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
COPY composer.json .
RUN composer install --no-interaction
# Use the production php.ini unless PHP_DEBUG=1 (defaults to 0)
ARG PHP_DEBUG=0
RUN [ "$PHP_DEBUG" = "1" ] && echo "Using development php.ini" || \
{ echo "Using production php.ini" && \
tar -xOvf /usr/src/php.tar.xz php-$PHP_VERSION/php.ini-production > /usr/local/etc/php/php.ini; \
}
COPY --from=builder /smr .
RUN rm -rf /var/www/html/ && ln -s "$(pwd)/htdocs" /var/www/html
# Make the upload directory writable by the apache user
RUN chown www-data ./htdocs/upload
# Leverage browser caching of static assets using apache's mod_headers
COPY apache/cache-static.conf /etc/apache2/conf-enabled/cache-static.conf
RUN a2enmod headers
# Store the git commit hash of the repo in the final image
COPY .git/HEAD .git/HEAD
COPY .git/refs .git/refs
RUN cat .git/$(cat .git/HEAD | awk '{print $2}') > git-commit