1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00
appwrite/Dockerfile

180 lines
6.1 KiB
Docker
Raw Normal View History

2020-04-14 21:28:52 +12:00
FROM ubuntu:18.04 AS builder
2019-10-06 13:09:19 +13:00
LABEL maintainer="team@appwrite.io"
ARG TESTING=false
ENV TZ=Asia/Tel_Aviv \
DEBIAN_FRONTEND=noninteractive \
2019-12-10 00:47:52 +13:00
PHP_VERSION=7.4 \
2020-04-14 21:28:52 +12:00
PHP_REDIS_VERSION=5.2.1
2019-10-06 13:09:19 +13:00
RUN \
apt-get update && \
2020-06-13 17:18:07 +12:00
apt-get install -y --no-install-recommends --no-install-suggests ca-certificates software-properties-common wget git openssl && \
2019-10-06 13:09:19 +13:00
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \
apt-get update && \
apt-get install -y --no-install-recommends --no-install-suggests make php$PHP_VERSION php$PHP_VERSION-dev zip unzip php$PHP_VERSION-zip && \
2019-11-29 20:34:13 +13:00
# Redis Extension
2019-10-06 13:09:19 +13:00
wget -q https://github.com/phpredis/phpredis/archive/$PHP_REDIS_VERSION.tar.gz && \
tar -xf $PHP_REDIS_VERSION.tar.gz && \
cd phpredis-$PHP_REDIS_VERSION && \
phpize$PHP_VERSION && \
./configure && \
make && \
2019-11-29 20:34:13 +13:00
# Composer
2020-06-13 17:18:07 +12:00
wget https://getcomposer.org/composer.phar && \
chmod +x ./composer.phar && \
2020-06-13 19:35:29 +12:00
mv ./composer.phar /usr/bin/composer && \
#Brotli
cd / && \
git clone https://github.com/eustas/ngx_brotli.git && \
cd ngx_brotli && git submodule update --init && cd ..
2019-10-06 13:09:19 +13:00
WORKDIR /usr/local/src/
2019-11-29 20:34:13 +13:00
# Updating PHP Dependencies and Auto-loading...
2019-10-06 13:09:19 +13:00
ENV TESTING=$TESTING
2019-11-29 20:34:13 +13:00
2019-10-06 13:09:19 +13:00
COPY composer.* /usr/local/src/
2019-11-29 20:34:13 +13:00
2019-10-06 13:09:19 +13:00
RUN composer update --ignore-platform-reqs --optimize-autoloader \
--no-plugins --no-scripts --prefer-dist \
`if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi`
2019-05-09 18:54:39 +12:00
FROM ubuntu:18.04
2019-08-01 07:39:31 +12:00
LABEL maintainer="team@appwrite.io"
2019-05-09 18:54:39 +12:00
2019-11-29 20:34:13 +13:00
ARG VERSION=dev
2019-10-06 13:09:19 +13:00
ENV TZ=Asia/Tel_Aviv \
DEBIAN_FRONTEND=noninteractive \
2019-12-10 00:47:52 +13:00
PHP_VERSION=7.4 \
2019-10-06 13:09:19 +13:00
_APP_ENV=production \
2020-03-01 19:33:19 +13:00
_APP_DOMAIN=localhost \
_APP_DOMAIN_TARGET=localhost \
2019-10-06 13:09:19 +13:00
_APP_HOME=https://appwrite.io \
_APP_EDITION=community \
_APP_OPTIONS_ABUSE=enabled \
2020-06-02 07:58:58 +12:00
_APP_OPTIONS_FORCE_HTTPS=disabled \
2019-10-06 13:09:19 +13:00
_APP_OPENSSL_KEY_V1=your-secret-key \
_APP_STORAGE_LIMIT=104857600 \
_APP_STORAGE_ANTIVIRUS=enabled \
2019-10-06 13:09:19 +13:00
_APP_REDIS_HOST=redis \
_APP_REDIS_PORT=6379 \
_APP_DB_HOST=mariadb \
_APP_DB_PORT=3306 \
_APP_DB_USER=root \
_APP_DB_PASS=password \
_APP_DB_SCHEMA=appwrite \
_APP_INFLUXDB_HOST=influxdb \
_APP_INFLUXDB_PORT=8086 \
_APP_STATSD_HOST=telegraf \
_APP_STATSD_PORT=8125 \
_APP_SMTP_HOST=smtp \
2019-11-29 20:34:13 +13:00
_APP_SMTP_PORT=25 \
2020-02-04 21:06:13 +13:00
_APP_SETUP=self-hosted \
2019-11-29 20:34:13 +13:00
_APP_VERSION=$VERSION
2019-08-19 03:22:03 +12:00
#ENV _APP_SMTP_SECURE ''
#ENV _APP_SMTP_USERNAME ''
#ENV _APP_SMTP_PASSWORD ''
2019-08-10 23:38:09 +12:00
2020-04-14 21:28:52 +12:00
COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/
2020-06-13 19:35:29 +12:00
COPY --from=builder /phpredis-5.2.1/modules/redis.so /usr/lib/php/20190902/
COPY --from=builder /ngx_brotli /ngx_brotli
2019-10-06 13:09:19 +13:00
2019-05-09 18:54:39 +12:00
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN \
2019-10-06 13:09:19 +13:00
apt-get update && \
2020-06-13 20:26:27 +12:00
apt-get install -y --no-install-recommends --no-install-suggests wget ca-certificates software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev openssl gnupg htop supervisor && \
2019-05-09 18:54:39 +12:00
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && \
2020-02-19 11:13:18 +13:00
add-apt-repository universe && \
add-apt-repository ppa:certbot/certbot && \
2019-10-06 13:09:19 +13:00
apt-get update && \
2020-06-13 17:18:07 +12:00
apt-get install -y --no-install-recommends --no-install-suggests php$PHP_VERSION php$PHP_VERSION-fpm \
2020-02-19 11:13:18 +13:00
php$PHP_VERSION-mysqlnd php$PHP_VERSION-curl php$PHP_VERSION-imagick php$PHP_VERSION-mbstring php$PHP_VERSION-dom webp certbot && \
2019-11-29 20:34:13 +13:00
# Nginx
2020-06-13 17:18:07 +12:00
wget http://nginx.org/download/nginx-1.19.0.tar.gz && \
tar -xzvf nginx-1.19.0.tar.gz && rm nginx-1.19.0.tar.gz && \
cd nginx-1.19.0 && \
./configure --prefix=/usr/share/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www-data \
--group=www-data \
--build=Ubuntu \
--with-http_gzip_static_module \
--with-http_ssl_module \
2020-06-13 19:35:29 +12:00
--with-http_v2_module \
--add-module=/ngx_brotli && \
2020-06-13 17:18:07 +12:00
make && \
make install && \
2020-06-13 20:26:27 +12:00
rm -rf ../nginx-1.19.0 && \
2019-11-29 20:34:13 +13:00
# Redis Extension
2019-10-06 13:09:19 +13:00
echo extension=redis.so >> /etc/php/$PHP_VERSION/fpm/conf.d/redis.ini && \
echo extension=redis.so >> /etc/php/$PHP_VERSION/cli/conf.d/redis.ini && \
2019-11-29 20:34:13 +13:00
# Cleanup
2019-05-09 18:54:39 +12:00
cd ../ && \
2020-06-13 20:48:28 +12:00
apt-get purge -y --auto-remove wget software-properties-common build-essential libpcre3-dev zlib1g-dev libssl-dev gnupg && \
2019-05-09 18:54:39 +12:00
apt-get clean && \
2020-06-13 19:35:29 +12:00
rm -rf /ngx_brotli && \
2019-05-09 18:54:39 +12:00
rm -rf /var/lib/apt/lists/*
# Set Upload Limit (default to 100MB)
2020-03-01 19:33:19 +13:00
RUN echo "upload_max_filesize = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
RUN echo "post_max_size = ${_APP_STORAGE_LIMIT}" >> /etc/php/$PHP_VERSION/fpm/conf.d/appwrite.ini
# Add logs file
RUN echo "" >> /var/log/appwrite.log
2019-05-09 18:54:39 +12:00
2019-11-29 20:34:13 +13:00
# Nginx Configuration (with self-signed ssl certificates)
2020-06-23 22:06:07 +12:00
COPY ./docker/nginx.conf.template /etc/nginx/nginx.conf.template
2019-11-17 10:18:21 +13:00
COPY ./docker/ssl/cert.pem /etc/nginx/ssl/cert.pem
COPY ./docker/ssl/key.pem /etc/nginx/ssl/key.pem
2019-05-09 18:54:39 +12:00
2019-11-29 20:34:13 +13:00
# PHP Configuration
2019-08-19 00:27:11 +12:00
RUN mkdir -p /var/run/php
2019-12-10 00:47:52 +13:00
COPY ./docker/www.conf /etc/php/$PHP_VERSION/fpm/pool.d/www.conf
2019-05-09 18:54:39 +12:00
2019-11-29 20:34:13 +13:00
# Add PHP Source Code
2019-10-01 18:00:39 +13:00
COPY ./app /usr/share/nginx/html/app
2020-05-21 19:00:06 +12:00
COPY ./bin /usr/local/bin
2019-10-09 21:24:47 +13:00
COPY ./docs /usr/share/nginx/html/docs
2019-10-01 18:00:39 +13:00
COPY ./public /usr/share/nginx/html/public
COPY ./src /usr/share/nginx/html/src
2019-10-06 13:09:19 +13:00
COPY --from=builder /usr/local/src/vendor /usr/share/nginx/html/vendor
2019-05-09 18:54:39 +12:00
2019-10-06 13:09:19 +13:00
RUN mkdir -p /storage/uploads && \
mkdir -p /storage/cache && \
2020-05-01 22:24:36 +12:00
mkdir -p /storage/config && \
mkdir -p /storage/certificates && \
2019-10-06 13:09:19 +13:00
chown -Rf www-data.www-data /storage/uploads && chmod -Rf 0755 /storage/uploads && \
2020-05-01 22:24:36 +12:00
chown -Rf www-data.www-data /storage/cache && chmod -Rf 0755 /storage/cache && \
chown -Rf www-data.www-data /storage/config && chmod -Rf 0755 /storage/config && \
chown -Rf www-data.www-data /storage/certificates && chmod -Rf 0755 /storage/certificates
2019-09-28 02:29:19 +12:00
2019-11-29 20:34:13 +13:00
# Supervisord Conf
2019-10-06 13:09:19 +13:00
COPY ./docker/supervisord.conf /etc/supervisord.conf
2020-03-21 23:06:44 +13:00
2020-05-21 19:00:06 +12:00
# Executables
RUN chmod +x /usr/local/bin/start
2020-06-15 20:01:48 +12:00
RUN chmod +x /usr/local/bin/doctor
2020-05-21 19:00:06 +12:00
RUN chmod +x /usr/local/bin/migrate
RUN chmod +x /usr/local/bin/test
2019-05-09 18:54:39 +12:00
2020-02-25 05:47:45 +13:00
# Letsencrypt Permissions
2020-02-25 21:42:14 +13:00
RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/
2020-02-25 05:47:45 +13:00
2019-05-09 18:54:39 +12:00
EXPOSE 80
2019-10-06 13:09:19 +13:00
WORKDIR /usr/share/nginx/html
2020-05-21 19:00:06 +12:00
CMD ["/bin/bash", "/usr/local/bin/start"]