]> jfr.im git - uguu.git/blame - docker/Dockerfile
refactoring
[uguu.git] / docker / Dockerfile
CommitLineData
b3c0237a 1FROM alpine:latest
0a6585a2 2
3ARG VERSION
4
b3c0237a
GJ
5# Install the needed software
6RUN apk add --no-cache curl nginx php8-fpm php8-sqlite3 php8-opcache sqlite nodejs git npm bash build-base supervisor
0a6585a2 7
b3c0237a
GJ
8# Create the www-data user and group
9RUN set -x ; \
10 addgroup -g 82 -S www-data ; \
11 adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
12
13# Link php bin
14RUN ln -s /usr/bin/php8 /usr/bin/php
15
16# Copy supervisor conf file
17COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
18
19# Set default workdir
0a6585a2 20WORKDIR /var/www/
21
22COPY docker/docker-entrypoint.sh .
23
b3c0237a
GJ
24# Download Uguu
25ADD https://git.pomf.se/Pomf/uguu/archive/v${VERSION}.tar.gz v${VERSION}.tar.gz
26RUN tar xvf v${VERSION}.tar.gz
0a6585a2 27
b3c0237a 28# Create the needed directories
0a6585a2 29RUN mkdir /var/www/uguu/dist && \
30 mkdir /var/www/db && \
31 mkdir /var/www/files
fca51030 32
b3c0237a 33# Create the Sqlite DB
0a6585a2 34RUN sqlite3 /var/www/db/uguu.sq3 -init /var/www/uguu/sqlite_schema.sql && \
b3c0237a 35 chown -R www-data:www-data /var/www && \
0a6585a2 36 chmod -R 775 /var/www/
37
b3c0237a 38# Fix script paths
0a6585a2 39RUN chmod a+x /var/www/uguu/checkdb.sh && \
40 chmod a+x /var/www/uguu/checkfiles.sh && \
41 sed -i 's#/path/to/files/#/var/www/uguu/files/#g' /var/www/uguu/checkfiles.sh && \
fca51030 42 sed -i 's#/path/to/db/uguu.sq3#/var/www/db/uguu.sq3#g' /var/www/uguu/checkdb.sh
0a6585a2 43
b3c0237a
GJ
44# Add scripts to cron
45RUN echo "0,30 * * * * bash /var/www/uguu/checkfiles.sh" >> /var/spool/cron/crontabs/www-data && \
46 echo "0,30 * * * * bash /var/www/uguu/checkdb.sh" >> /var/spool/cron/crontabs/www-data
47
48# Copy Nginx Server conf
49COPY docker/uguu.conf /etc/nginx/http.d/
50
51# Copy SSL certs
52COPY docker/ssl /etc/ssl
53
54# Copy Uguu config
fca51030 55COPY dist.json /var/www/uguu/dist.json
b3c0237a
GJ
56
57# Give permissions to www-data
58RUN chown -R www-data:www-data /run /var/lib/php8 /var/lib/nginx /var/log/nginx /var/log/php8 /etc/nginx /etc/php8
59
60# Change user to www-data
61USER www-data
0a6585a2 62
b3c0237a 63# Expose port 80 from the container
0a6585a2 64EXPOSE 80
65
ccf3370a
GJ
66# Expose port 443 from the container
67EXPOSE 443
68
b3c0237a 69# Load entrypoint
fca51030 70ENTRYPOINT [ "bash", "/var/www/docker-entrypoint.sh" ]