FROM gitea.dege.au/docker/php:8.3-fpm-pgsql-server

VOLUME [ "${COMPOSER_HOME}", "/var/lib/zerotier-one" ]

# Add Zerotier
RUN apk add zerotier-one -X http://dl-cdn.alpinelinux.org/alpine/v3.17/community --no-cache

COPY docker/init-container /sbin/
COPY . /var/www/html/

RUN mkdir -p ${COMPOSER_HOME} \
	&& ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true \
	&& touch .composer.refresh \
	&& mv .env.example .env \
	&& apk add --no-cache git \
	&& APP_TIMEZONE=UTC FORCE_PERMS=1 NGINX_START=FALSE /sbin/init \
	&& apk del --no-cache git \
	&& chmod +x /var/www/html/artisan /var/www/html/init-php.sh \
	&& rm -rf ${COMPOSER_HOME}/* composer.lock storage/logs/*.log