chore: upgrade dockerfiles (#3095)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
.circleci/
|
||||
.azure/
|
||||
.vscode/
|
||||
.composer/
|
||||
.git/
|
||||
.gitattributes
|
||||
|
||||
@@ -68,6 +68,7 @@ endif
|
||||
DESTDIR := monica-$(BUILD)
|
||||
ASSETS := monica-assets-$(BUILD)
|
||||
DOCKER_IMAGE := monicahq/monicahq
|
||||
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
default: build
|
||||
|
||||
@@ -81,11 +82,11 @@ docker:
|
||||
$(MAKE) docker_tag
|
||||
$(MAKE) docker_push
|
||||
|
||||
docker_build: docker_build_apache docker_build_fpm
|
||||
docker_build: docker_build_apache docker_build_fpm docker_build_php_apache
|
||||
|
||||
docker_build_apache:
|
||||
docker build \
|
||||
--build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--build-arg BUILD_DATE=$(BUILD_DATE) \
|
||||
--build-arg VCS_REF=$(GIT_REF) \
|
||||
--build-arg COMMIT=$(GIT_COMMIT) \
|
||||
--build-arg VERSION=$(BUILD) \
|
||||
@@ -93,9 +94,19 @@ docker_build_apache:
|
||||
-t $(DOCKER_IMAGE) .
|
||||
docker images
|
||||
|
||||
docker_build_php_apache:
|
||||
docker build \
|
||||
--build-arg BUILD_DATE=$(BUILD_DATE) \
|
||||
--build-arg VCS_REF=$(GIT_REF) \
|
||||
--build-arg COMMIT=$(GIT_COMMIT) \
|
||||
--build-arg VERSION=$(BUILD) \
|
||||
-f scripts/docker/php-apache/Dockerfile \
|
||||
-t $(DOCKER_IMAGE):php-apache .
|
||||
docker images
|
||||
|
||||
docker_build_fpm:
|
||||
docker build \
|
||||
--build-arg BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--build-arg BUILD_DATE=$(BUILD_DATE) \
|
||||
--build-arg VCS_REF=$(GIT_REF) \
|
||||
--build-arg COMMIT=$(GIT_COMMIT) \
|
||||
--build-arg VERSION=$(BUILD) \
|
||||
@@ -116,24 +127,35 @@ docker_squash:
|
||||
docker_tag:
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(BUILD)
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):apache
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):alpine
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(BUILD)-apache
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(BUILD)-alpine
|
||||
docker tag $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):$(BUILD)-alpine-apache
|
||||
docker tag $(DOCKER_IMAGE):fpm $(DOCKER_IMAGE):$(BUILD)-fpm
|
||||
docker tag $(DOCKER_IMAGE):fpm $(DOCKER_IMAGE):$(BUILD)-alpine-fpm
|
||||
docker tag $(DOCKER_IMAGE):php-apache $(DOCKER_IMAGE):$(BUILD)-php-apache
|
||||
docker images
|
||||
|
||||
docker_push: docker_tag
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-apache
|
||||
docker push $(DOCKER_IMAGE):apache
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-fpm
|
||||
docker push $(DOCKER_IMAGE):fpm
|
||||
docker push $(DOCKER_IMAGE):latest
|
||||
docker push $(DOCKER_IMAGE):fpm
|
||||
docker push $(DOCKER_IMAGE):php-apache
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)
|
||||
docker push $(DOCKER_IMAGE):apache
|
||||
docker push $(DOCKER_IMAGE):alpine
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-apache
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-alpine
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-alpine-apache
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-fpm
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-alpine-fpm
|
||||
docker push $(DOCKER_IMAGE):$(BUILD)-php-apache
|
||||
|
||||
docker_push_bintray: .deploy.json
|
||||
docker tag $(DOCKER_IMAGE) monicahq-docker-docker.bintray.io/$(DOCKER_IMAGE):$(BUILD)
|
||||
docker push monicahq-docker-docker.bintray.io/$(DOCKER_IMAGE):$(BUILD)
|
||||
BUILD=$(BUILD) scripts/tests/fix-bintray.sh
|
||||
|
||||
.PHONY: docker docker_build docker_build_apache docker_build_fpm docker_tag docker_push docker_push_bintray
|
||||
.PHONY: docker docker_build docker_build_apache docker_build_fpm docker_build_php_apache docker_tag docker_push docker_push_bintray
|
||||
|
||||
build:
|
||||
composer install --no-interaction --no-suggest --ignore-platform-reqs
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
LoadModule rewrite_module modules/mod_rewrite.so
|
||||
|
||||
ServerName localhost
|
||||
|
||||
<VirtualHost *:80>
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/monica/public
|
||||
@@ -18,9 +14,6 @@ ServerName localhost
|
||||
</IfModule>
|
||||
|
||||
<IfModule log_config_module>
|
||||
ErrorLog logs/error.log
|
||||
CustomLog logs/access.log combined
|
||||
|
||||
ErrorLog /dev/stderr
|
||||
CustomLog /dev/stdout combined
|
||||
</IfModule>
|
||||
|
||||
@@ -48,9 +48,7 @@ RUN apk add netcat-openbsd \
|
||||
#- sentry/sentry
|
||||
php7-curl \
|
||||
#- cbor-php (webauthn)
|
||||
php7-gmp \
|
||||
# apache variant
|
||||
apache2 php7-apache2
|
||||
php7-gmp
|
||||
|
||||
# Create a user to own all the code and assets and give them a working
|
||||
# directory
|
||||
@@ -86,6 +84,13 @@ RUN mkdir -p bootstrap/cache; \
|
||||
chmod -R g+w bootstrap/cache storage
|
||||
COPY .env.example .env
|
||||
|
||||
# Php
|
||||
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
|
||||
PHP_OPCACHE_MAX_ACCELERATED_FILES="20000" \
|
||||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
|
||||
COPY scripts/docker/opcache.ini /usr/php7/conf.d/opcache.ini
|
||||
|
||||
# Sentry
|
||||
RUN echo $VCS_REF > .sentry-release; \
|
||||
echo $COMMIT > .sentry-commit; \
|
||||
@@ -121,8 +126,11 @@ COPY scripts/docker/entrypoint.sh /usr/local/bin/
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
# Apache2
|
||||
RUN apk add apache2 php7-apache2
|
||||
COPY scripts/docker/apache2-foreground /usr/local/sbin/
|
||||
COPY scripts/docker/000-default.conf /etc/apache2/conf.d/
|
||||
RUN echo 'LoadModule rewrite_module modules/mod_rewrite.so' > /etc/apache2/conf.d/rewrite.conf
|
||||
RUN echo 'ServerName "monica"' > /etc/apache2/conf.d/hostname.conf
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Run fpm
|
||||
if [ -f /etc/apache2/conf-enabled/php7.3-fpm.conf ]; then
|
||||
service php7.3-fpm start
|
||||
fi
|
||||
|
||||
# Run apache2
|
||||
mkdir -p /run/apache2
|
||||
rm -f /run/apache2/httpd.pid
|
||||
|
||||
@@ -38,7 +38,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm7" ]; then
|
||||
chown -R monica:apache ${STORAGE}
|
||||
chmod -R g+rw ${STORAGE}
|
||||
|
||||
if [[ -z "${APP_KEY:-}" || "$APP_KEY" == "ChangeMeBy32KeyLengthOrGenerated" ]]; then
|
||||
if [ -z "${APP_KEY:-}" || "$APP_KEY" = "ChangeMeBy32KeyLengthOrGenerated" ]; then
|
||||
${ARTISAN} key:generate --no-interaction
|
||||
else
|
||||
echo "APP_KEY already set"
|
||||
@@ -48,13 +48,13 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm7" ]; then
|
||||
waitfordb
|
||||
${ARTISAN} monica:update --force -vv
|
||||
|
||||
if [[ -n "${SENTRY_SUPPORT:-}" && "$SENTRY_SUPPORT" == "true" && -z "${SENTRY_NORELEASE:-}" && -n "${SENTRY_ENV:-}" ]]; then
|
||||
if [ -n "${SENTRY_SUPPORT:-}" && "$SENTRY_SUPPORT" = "true" && -z "${SENTRY_NORELEASE:-}" && -n "${SENTRY_ENV:-}" ]; then
|
||||
commit=$(cat .sentry-commit)
|
||||
release=$(cat .sentry-release)
|
||||
${ARTISAN} sentry:release --release="$release" --commit="$commit" --environment="$SENTRY_ENV" -v || true
|
||||
fi
|
||||
|
||||
if [[ ! -f "${STORAGE}/oauth-public.key" || ! -f "${STORAGE}/oauth-private.key" ]]; then
|
||||
if [ ! -f "${STORAGE}/oauth-public.key" || ! -f "${STORAGE}/oauth-private.key" ]; then
|
||||
echo "Passport keys creation ..."
|
||||
${ARTISAN} passport:keys
|
||||
${ARTISAN} passport:client --personal --no-interaction
|
||||
@@ -62,8 +62,12 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm7" ]; then
|
||||
fi
|
||||
|
||||
# Run cron
|
||||
if [ -f "/usr/sbin/crond" ]; then
|
||||
crond -b -l 0 -L /dev/stdout
|
||||
elif [ -f "/etc/init.d/cron" ]; then
|
||||
service cron start
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
docker-php-entrypoint $@
|
||||
|
||||
@@ -48,9 +48,7 @@ RUN apk add netcat-openbsd \
|
||||
#- sentry/sentry
|
||||
php7-curl \
|
||||
#- cbor-php (webauthn)
|
||||
php7-gmp \
|
||||
# fpm variant
|
||||
php7-fpm
|
||||
php7-gmp
|
||||
|
||||
# Create a user to own all the code and assets and give them a working
|
||||
# directory
|
||||
@@ -86,6 +84,13 @@ RUN mkdir -p bootstrap/cache; \
|
||||
chmod -R g+w bootstrap/cache storage
|
||||
COPY .env.example .env
|
||||
|
||||
# Php
|
||||
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
|
||||
PHP_OPCACHE_MAX_ACCELERATED_FILES="20000" \
|
||||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
|
||||
COPY scripts/docker/opcache.ini /usr/php7/conf.d/opcache.ini
|
||||
|
||||
# Sentry
|
||||
RUN echo $VCS_REF > .sentry-release; \
|
||||
echo $COMMIT > .sentry-commit; \
|
||||
@@ -121,6 +126,7 @@ COPY scripts/docker/entrypoint.sh /usr/local/bin/
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
# FPM
|
||||
RUN apk add php7-fpm
|
||||
RUN set -ex && \
|
||||
cd /etc/php7/php-fpm.d && \
|
||||
{ \
|
||||
@@ -130,6 +136,7 @@ RUN set -ex && \
|
||||
echo '[www]'; \
|
||||
echo 'access.log = /dev/stdout'; \
|
||||
echo 'catch_workers_output = yes'; \
|
||||
echo 'clear_env = no'; \
|
||||
} | tee docker.conf && \
|
||||
{ \
|
||||
echo '[global]'; \
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[opcache]
|
||||
|
||||
opcache.enable=1
|
||||
opcache.revalidate_freq=0
|
||||
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
|
||||
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}
|
||||
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}
|
||||
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}
|
||||
opcache.interned_strings_buffer=16
|
||||
|
||||
opcache.fast_shutdown=1
|
||||
@@ -0,0 +1,132 @@
|
||||
FROM php:7.3-apache
|
||||
|
||||
# Build-time metadata as defined at http://label-schema.org
|
||||
ARG BUILD_DATE
|
||||
ARG VCS_REF
|
||||
ARG COMMIT
|
||||
ARG VERSION
|
||||
LABEL org.label-schema.build-date=$BUILD_DATE \
|
||||
org.label-schema.name="MonicaHQ, the Personal Relationship Manager" \
|
||||
org.label-schema.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \
|
||||
org.label-schema.url="https://monicahq.com" \
|
||||
org.label-schema.vcs-ref=$VCS_REF \
|
||||
org.label-schema.vcs-url="https://github.com/monicahq/monica" \
|
||||
org.label-schema.vendor="Monica" \
|
||||
org.label-schema.version=$VERSION \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y --no-install-recommends install \
|
||||
git cron netcat apt apt-transport-https \
|
||||
locales sudo openssh-client ca-certificates \
|
||||
curl unzip zip tar bzip2 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install common extensions
|
||||
RUN apt-get update && \
|
||||
apt-get -y --no-install-recommends install libicu-dev zlib1g-dev libzip-dev libpng-dev libxml2-dev libfreetype6-dev libjpeg62-turbo-dev libgmp-dev && \
|
||||
apt-get -y clean && \
|
||||
docker-php-ext-configure intl && \
|
||||
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
|
||||
docker-php-ext-install -j$(nproc) \
|
||||
intl \
|
||||
zip \
|
||||
json \
|
||||
iconv \
|
||||
bcmath \
|
||||
gd \
|
||||
gmp \
|
||||
pdo_mysql \
|
||||
mysqli \
|
||||
soap \
|
||||
mbstring \
|
||||
opcache && \
|
||||
apt-get -y remove libicu-dev icu-devtools && \
|
||||
apt-get -y autoremove && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a user to own all the code and assets and give them a working
|
||||
# directory
|
||||
RUN mkdir -p /var/www/monica && \
|
||||
addgroup --gid 1001 monica && \
|
||||
adduser --uid 1001 --ingroup monica --home /var/www/monica --shell /bin/bash --no-create-home monica && \
|
||||
adduser monica www-data && \
|
||||
chown -R monica:www-data /var/www/monica && \
|
||||
echo 'monica ALL=NOPASSWD: ALL' >> /etc/sudoers.d/50-monica && \
|
||||
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >> /etc/sudoers.d/env_keep
|
||||
WORKDIR /var/www/monica
|
||||
|
||||
|
||||
# Copy the local (outside Docker) source into the working directory,
|
||||
# copy system files into their proper homes, and set file ownership
|
||||
# correctly
|
||||
COPY readme.md \
|
||||
CONTRIBUTING.md \
|
||||
CHANGELOG.md \
|
||||
CONTRIBUTORS \
|
||||
LICENSE \
|
||||
artisan \
|
||||
composer.json \
|
||||
composer.lock \
|
||||
./
|
||||
COPY app ./app
|
||||
COPY bootstrap ./bootstrap
|
||||
COPY config ./config
|
||||
COPY database ./database
|
||||
COPY public ./public
|
||||
COPY resources ./resources
|
||||
COPY routes ./routes
|
||||
|
||||
RUN mkdir -p bootstrap/cache; \
|
||||
mkdir -p storage; \
|
||||
chown -R monica:www-data .; \
|
||||
chgrp -R www-data bootstrap/cache storage; \
|
||||
chmod -R g+w bootstrap/cache storage
|
||||
COPY .env.example .env
|
||||
|
||||
# Php
|
||||
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
|
||||
PHP_OPCACHE_MAX_ACCELERATED_FILES="20000" \
|
||||
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
|
||||
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
|
||||
COPY scripts/docker/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
|
||||
|
||||
# Sentry
|
||||
RUN echo $VCS_REF > .sentry-release; \
|
||||
echo $COMMIT > .sentry-commit; \
|
||||
mkdir -p /root/.local/bin && \
|
||||
curl -sL https://sentry.io/get-cli/ | INSTALL_DIR=/root/.local/bin bash
|
||||
|
||||
# Composer installation
|
||||
COPY scripts/docker/install-composer.sh /usr/local/sbin/
|
||||
RUN install-composer.sh
|
||||
|
||||
# Install composer dependencies
|
||||
USER monica
|
||||
RUN composer global require hirak/prestissimo; \
|
||||
composer install --no-interaction --no-suggest --no-progress --no-dev; \
|
||||
composer global remove hirak/prestissimo; \
|
||||
composer clear-cache
|
||||
USER root
|
||||
|
||||
# Set crontab for schedules
|
||||
RUN set -ex && \
|
||||
cd /etc/cron.hourly && \
|
||||
{ \
|
||||
echo '#!/bin/sh'; \
|
||||
echo '/usr/bin/php /var/www/monica/artisan schedule:run -v'; \
|
||||
} | tee monica && \
|
||||
chmod a+x monica
|
||||
|
||||
COPY scripts/docker/entrypoint.sh /usr/local/bin/
|
||||
RUN sed -ri -e 's!monica:apache!monica:www-data!g' /usr/local/bin/entrypoint.sh
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
|
||||
# Apache2
|
||||
COPY scripts/docker/000-default.conf /etc/apache2/sites-available/
|
||||
RUN echo 'ServerName "monica"' > /etc/apache2/conf-available/hostname.conf
|
||||
RUN a2enconf hostname
|
||||
RUN a2enmod rewrite cache headers
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["apache2-foreground"]
|
||||
Reference in New Issue
Block a user