]> jfr.im git - uguu.git/blob - docker/Dockerfile
fix multiple uploads in same request
[uguu.git] / docker / Dockerfile
1 FROM --platform=linux/amd64 debian:bullseye-slim
2
3 # Install needed software
4 RUN apt-get update
5 RUN apt-get install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 curl cron socat
6 RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
7 RUN curl -fsSL https://packages.sury.org/php/apt.gpg| gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg
8 RUN apt-get update
9 RUN apt-get upgrade -y
10 RUN curl -o nodejssetup.sh https://deb.nodesource.com/setup_19.x
11 RUN chmod a+x nodejssetup.sh
12 RUN ./nodejssetup.sh
13 RUN apt-get install -y nodejs gcc g++ make
14 RUN apt-get install -y build-essential nginx-full php8.1-fpm php8.1 sqlite3 php8.1-sqlite3 \
15 php8.1-curl php8.1-cli php8.1-lz4 php8.1-pgsql \
16 php8.1-mcrypt php8.1-mysql php8.1-xdebug php8.1-zip \
17 php8.1-common php8.1-readline php8.1-bcmath php8.1-common php8.1-xml
18
19 # Set ENV values for configuration
20 ARG DOMAIN
21 ENV DOMAIN=$DOMAIN
22
23 ARG FILE_DOMAIN
24 ENV FILE_DOMAIN=$FILE_DOMAIN
25
26 ARG CONTACT_EMAIL
27 ENV CONTACT_EMAIL=$CONTACT_EMAIL
28
29 ARG MAX_SIZE
30 ENV MAX_SIZE=$MAX_SIZE
31
32 ARG EXPIRE_TIME
33 ENV EXPIRE_TIME=$EXPIRE_TIME
34
35 # Set default workdir
36 WORKDIR /var/www/
37
38 COPY docker/docker-entrypoint.sh .
39
40 # Decompress into Docker
41 COPY docker/uguuForDocker.tar.gz /var/www/
42 RUN mkdir /var/www/uguu
43 RUN tar -xvf uguuForDocker.tar.gz -C uguu
44
45 # Create the needed directories
46 RUN mkdir /var/www/files && \
47 mkdir /var/www/db
48
49 # Create the Sqlite DB
50 RUN sqlite3 /var/www/db/uguu.sq3 -init /var/www/uguu/src/static/dbSchemas/sqlite_schema.sql "" && \
51 chown -R www-data:www-data /var/www && \
52 chmod -R 775 /var/www/
53
54 # Add scripts to cron
55 RUN echo "0,30 * * * * bash /var/www/uguu/src/static/scripts/checkfiles.sh" >> /var/spool/cron/crontabs/www-data && \
56 echo "0,30 * * * * bash /var/www/uguu/src/static/scripts/checkdb.sh" >> /var/spool/cron/crontabs/www-data
57
58 # Fix script paths
59 RUN chmod a+x /var/www/uguu/src/static/scripts/checkdb.sh && \
60 chmod a+x /var/www/uguu/src/static/scripts/checkfiles.sh && \
61 sed -i 's#/path/to/files/#/var/www/uguu/files/#g' /var/www/uguu/src/static/scripts/checkfiles.sh && \
62 sed -i 's#/path/to/db/uguu.sq3#/var/www/db/uguu.sq3#g' /var/www/uguu/src/static/scripts/checkdb.sh
63
64 # Copy Nginx Server conf
65 COPY docker/nginx/uguu.conf /etc/nginx/sites-enabled/uguu.conf
66 COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
67
68 # Modify expire time
69 RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkfiles.sh
70 RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkdb.sh
71
72 # Modify nginx values
73 RUN sed -i "s#XMAINDOMAINX#${DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
74 RUN sed -i "s#XFILESDOMAINX#${FILE_DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
75 RUN sed -i "s#client_max_body_size 128M#client_max_body_size ${MAX_SIZE}M#g" /etc/nginx/nginx.conf
76
77 # Modify php-fpm values
78 RUN sed -i "s#post_max_size = 8M#post_max_size = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
79 RUN sed -i "s#upload_max_filesize = 2M#upload_max_filesize = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
80
81 # Copy Uguu config
82 COPY src/config.json /var/www/uguu/config.json
83
84 # Expose port 80 from the container
85 EXPOSE 80
86
87 # Expose port 443 from the container
88 EXPOSE 443
89
90 # Install acme.sh
91 RUN curl -o acmeinstall.sh https://get.acme.sh
92 RUN chmod a+x acmeinstall.sh
93 RUN ./acmeinstall.sh
94
95 # Load entrypoint
96 ENTRYPOINT [ "bash", "/var/www/docker-entrypoint.sh" ]