forked from AzuraCast/AzuraCast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
207 lines (156 loc) · 5.54 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# syntax=docker/dockerfile:1
#
# Golang dependencies build step
#
FROM golang:1.23-bookworm AS go-dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends openssl git
RUN go install github.com/jwilder/dockerize@v0.8.0
RUN go install github.com/aptible/supercronic@v0.2.33
RUN go install github.com/centrifugal/centrifugo/v5@v5.4.6
RUN strip /go/bin/*
#
# MariaDB dependencies build step
#
FROM mariadb:11.2-jammy AS mariadb
#
# Built-in docs build step
#
FROM ghcr.io/azuracast/azuracast.com:builtin AS docs
#
# Icecast-KH with AzuraCast customizations build step
#
FROM ghcr.io/azuracast/icecast-kh-ac:2024-02-13 AS icecast
#
# PHP Extension Installer build step
#
FROM mlocati/php-extension-installer AS php-extension-installer
# ---
FROM scratch AS dependencies
# Add PHP extension installer tool
COPY --from=php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
# Add Go dependencies
COPY --from=go-dependencies /go/bin/dockerize /usr/local/bin
COPY --from=go-dependencies /go/bin/supercronic /usr/local/bin/supercronic
COPY --from=go-dependencies /go/bin/centrifugo /usr/local/bin/centrifugo
# Add MariaDB dependencies
COPY --from=mariadb /usr/local/bin/healthcheck.sh /usr/local/bin/db_healthcheck.sh
COPY --from=mariadb /usr/local/bin/docker-entrypoint.sh /usr/local/bin/db_entrypoint.sh
# Add Icecast
COPY --from=icecast /usr/local/bin/icecast /usr/local/bin/icecast
COPY --from=icecast /usr/local/share/icecast /usr/local/share/icecast
#
# Final build image
#
FROM php:8.3-fpm-bookworm AS pre-final
ENV TZ="UTC" \
LANGUAGE="en_US.UTF-8" \
LC_ALL="en_US.UTF-8" \
LANG="en_US.UTF-8" \
LC_TYPE="en_US.UTF-8"
COPY --link --from=dependencies / /
# Run base build process
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
bash /bd_build/prepare.sh && \
bash /bd_build/add_user.sh && \
bash /bd_build/cleanup.sh
# Build each set of dependencies in their own step for cacheability.
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
--mount=type=bind,source=./util/docker/supervisor,target=/bd_build/supervisor,rw \
bash /bd_build/supervisor/setup.sh && \
bash /bd_build/cleanup.sh
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
--mount=type=bind,source=./util/docker/stations,target=/bd_build/stations,rw \
bash /bd_build/stations/setup.sh && \
bash /bd_build/cleanup.sh
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
--mount=type=bind,source=./util/docker/web,target=/bd_build/web,rw \
bash /bd_build/web/setup.sh && \
bash /bd_build/cleanup.sh
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
--mount=type=bind,source=./util/docker/mariadb,target=/bd_build/mariadb,rw \
bash /bd_build/mariadb/setup.sh && \
bash /bd_build/cleanup.sh
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
--mount=type=bind,source=./util/docker/redis,target=/bd_build/redis,rw \
bash /bd_build/redis/setup.sh && \
bash /bd_build/cleanup.sh
RUN --mount=type=bind,source=./util/docker/common,target=/bd_build,rw \
bash /bd_build/chown_dirs.sh
# Add built-in docs
COPY --from=docs --chown=azuracast:azuracast /dist /var/azuracast/docs
USER azuracast
RUN touch /var/azuracast/.docker
USER root
VOLUME "/var/azuracast/stations"
VOLUME "/var/azuracast/backups"
VOLUME "/var/lib/mysql"
VOLUME "/var/azuracast/storage/uploads"
VOLUME "/var/azuracast/storage/shoutcast2"
VOLUME "/var/azuracast/storage/stereo_tool"
VOLUME "/var/azuracast/storage/geoip"
VOLUME "/var/azuracast/storage/sftpgo"
VOLUME "/var/azuracast/storage/acme"
EXPOSE 80 443 2022
EXPOSE 8000-8999
# Sensible default environment variables.
ENV LANG="en_US.UTF-8" \
PATH="${PATH}:/var/azuracast/storage/shoutcast2" \
APPLICATION_ENV="production" \
MYSQL_HOST="localhost" \
MYSQL_PORT=3306 \
MYSQL_USER="azuracast" \
MYSQL_PASSWORD="azur4c457" \
MYSQL_DATABASE="azuracast" \
ENABLE_REDIS="true" \
REDIS_HOST="localhost" \
REDIS_PORT=6379 \
REDIS_DB=0 \
NGINX_RADIO_PORTS="default" \
NGINX_WEBDJ_PORTS="default" \
COMPOSER_PLUGIN_MODE="false" \
ADDITIONAL_MEDIA_SYNC_WORKER_COUNT=0 \
PROFILING_EXTENSION_ENABLED=0 \
PROFILING_EXTENSION_ALWAYS_ON=0 \
PROFILING_EXTENSION_HTTP_KEY=dev \
PROFILING_EXTENSION_HTTP_IP_WHITELIST=* \
ENABLE_WEB_UPDATER="true"
#
# Development Build
#
FROM pre-final AS development
# Dev build step
COPY ./util/docker/common /bd_build/
COPY ./util/docker/dev /bd_build/dev
RUN bash /bd_build/dev/setup.sh \
&& bash /bd_build/cleanup.sh \
&& rm -rf /bd_build
USER azuracast
WORKDIR /var/azuracast/www
COPY --chown=azuracast:azuracast . .
RUN composer install --no-ansi --no-interaction \
&& composer clear-cache
RUN npm ci --include=dev \
&& npm cache clean --force
USER root
# Sensible default environment variables.
ENV APPLICATION_ENV="development" \
PROFILING_EXTENSION_ENABLED=1 \
ENABLE_WEB_UPDATER="false"
# Entrypoint and default command
ENTRYPOINT ["tini", "--", "/usr/local/bin/my_init"]
CMD ["--no-main-command"]
#
# Final build (Just environment vars and squishing the FS)
#
FROM pre-final AS final
USER azuracast
WORKDIR /var/azuracast/www
COPY --chown=azuracast:azuracast . .
RUN composer install --no-dev --no-ansi --no-autoloader --no-interaction \
&& composer dump-autoload --optimize --classmap-authoritative \
&& composer clear-cache
USER root
# Entrypoint and default command
ENTRYPOINT ["tini", "--", "/usr/local/bin/my_init"]
CMD ["--no-main-command"]