forked from koel/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
107 lines (87 loc) · 2.8 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
FROM php:7.3.15-alpine as php-builder
# The version and repository to clone koel from.
ARG KOEL_CLONE_SOURCE=https://github.com/koel/koel.git
ARG KOEL_VERSION_REF=v4.4.0
# Install git and composer
RUN apk add --no-cache composer \
git \
&& docker-php-ext-install exif
# Change to a restricted user.
USER www-data
# Shallow-clone the koel repository and remove anything not necessary for production
RUN git clone ${KOEL_CLONE_SOURCE} -b ${KOEL_VERSION_REF} --recurse-submodules --single-branch --depth 1 /tmp/koel && \
cd /tmp/koel && \
rm -rf .editorconfig \
.eslintignore \
.git \
.gitattributes \
.github \
.gitignore \
.gitmodules \
.gitpod.dockerfile \
.gitpod.yml \
.travis.yml \
cypress \
cypress.json \
nitpick.json \
phpunit.xml \
resources/artifacts \
tests
# Place artifacts here.
WORKDIR /tmp/koel
# Install runtime dependencies.
RUN composer install --no-dev --optimize-autoloader
# Install and build frontend.
FROM alpine:3.12.0 as front-builder
# Add nodejs and yarn. bash and the other 8 deps are needed to build pngquant, which is a dev dependency for koel...
RUN apk add --no-cache nodejs \
python2 python3 bash lcms2-dev libpng-dev gcc g++ make autoconf automake \
yarn
# Copy sources from php builder
COPY --from=php-builder /tmp/koel /tmp/koel
# Install, build frontend assets and then delete the sources to save disk space
RUN cd /tmp/koel/resources/assets && \
# Skip cypress download and installation. It is not needed for a production image
yarn install --non-interactive --network-timeout 100000 && \
cd /tmp/koel/ && \
CYPRESS_INSTALL_BINARY=0 yarn install --non-interactive && \
yarn run production && \
rm -rf /tmp/koel/node_modules \
/tmp/koel/resources/assets
# The runtime image.
FROM php:7.3.15-apache-buster
# Install dependencies.
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
libapache2-mod-xsendfile \
libzip-dev \
zip \
ffmpeg \
libpng-dev \
libjpeg62-turbo-dev \
&& docker-php-ext-configure gd --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install \
zip \
pdo_mysql \
exif \
gd \
&& apt-get clean
# Copy Apache configuration
COPY ./apache.conf /etc/apache2/sites-available/000-default.conf
# Deploy Apache configuration
RUN a2enmod rewrite
# Copy artifacts from build stage.
COPY --from=front-builder --chown=www-data:www-data /tmp/koel /var/www/html
# Music volume
VOLUME ["/music"]
ENV FFMPEG_PATH=/usr/bin/ffmpeg \
MEDIA_PATH=/music \
STREAMING_METHOD=x-sendfile
# Setup bootstrap script.
COPY koel-entrypoint /usr/local/bin/
ENTRYPOINT ["koel-entrypoint"]
CMD ["apache2-foreground"]
EXPOSE 80
# Check that the homepage is displayed
HEALTHCHECK --interval=5m --timeout=5s \
CMD curl -f http://localhost/ || exit 1