From 23856439c78db83b73d7a974ed05cbfb642a6777 Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Fri, 4 Sep 2020 07:53:07 +0200 Subject: [PATCH] docs: update docker doc (#4408) --- .azure/azure.sig | 26 +- .azure/step-docker-build.yml | 11 - .azure/step-docker-push-github.yml | 9 - .azure/step-docker-push.yml | 19 -- Dockerfile | 1 - Makefile | 88 ------ azure-pipelines.yml | 16 -- docker-compose.yml | 31 --- docs/installation/docker-mysql.md | 35 --- docs/installation/providers/docker.md | 253 ++---------------- docs/installation/ssl.md | 4 +- .../docker-compose.yml | 121 --------- .../proxy/Dockerfile | 3 - .../proxy/vhost.conf | 2 - .../web/Dockerfile | 9 - .../web/nginx.conf | 161 ----------- .../.examples/nginx-proxy/docker-compose.yml | 127 --------- .../.examples/nginx-proxy/proxy/Dockerfile | 3 - .../.examples/nginx-proxy/proxy/vhost.conf | 2 - .../.examples/nginx-proxy/web/Dockerfile | 9 - .../.examples/nginx-proxy/web/nginx.conf | 161 ----------- scripts/docker/.examples/readme.md | 65 ----- .../supervisor/apache/app/Dockerfile | 4 - .../supervisor/apache/app/supervisord.conf | 30 --- .../supervisor/apache/docker-compose.yml | 30 --- .../.examples/supervisor/fpm/app/Dockerfile | 4 - .../supervisor/fpm/app/supervisord.conf | 30 --- .../supervisor/fpm/docker-compose.yml | 38 --- .../.examples/supervisor/fpm/web/Dockerfile | 9 - .../.examples/supervisor/fpm/web/nginx.conf | 161 ----------- .../supervisor/php-apache/app/Dockerfile | 4 - .../php-apache/app/supervisord.conf | 30 --- .../supervisor/php-apache/docker-compose.yml | 30 --- scripts/docker/apache/Dockerfile | 164 ------------ scripts/docker/fpm/Dockerfile | 177 ------------ scripts/docker/php-apache/Dockerfile | 186 ------------- scripts/docker/php-apache/cron.sh | 4 - 37 files changed, 32 insertions(+), 2025 deletions(-) delete mode 100644 .azure/step-docker-build.yml delete mode 100644 .azure/step-docker-push-github.yml delete mode 100644 .azure/step-docker-push.yml delete mode 120000 Dockerfile delete mode 100644 docker-compose.yml delete mode 100644 docs/installation/docker-mysql.md delete mode 100644 scripts/docker/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml delete mode 100644 scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/Dockerfile delete mode 100644 scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/vhost.conf delete mode 100644 scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/Dockerfile delete mode 100644 scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/nginx.conf delete mode 100644 scripts/docker/.examples/nginx-proxy/docker-compose.yml delete mode 100644 scripts/docker/.examples/nginx-proxy/proxy/Dockerfile delete mode 100644 scripts/docker/.examples/nginx-proxy/proxy/vhost.conf delete mode 100644 scripts/docker/.examples/nginx-proxy/web/Dockerfile delete mode 100644 scripts/docker/.examples/nginx-proxy/web/nginx.conf delete mode 100644 scripts/docker/.examples/readme.md delete mode 100644 scripts/docker/.examples/supervisor/apache/app/Dockerfile delete mode 100644 scripts/docker/.examples/supervisor/apache/app/supervisord.conf delete mode 100644 scripts/docker/.examples/supervisor/apache/docker-compose.yml delete mode 100644 scripts/docker/.examples/supervisor/fpm/app/Dockerfile delete mode 100644 scripts/docker/.examples/supervisor/fpm/app/supervisord.conf delete mode 100644 scripts/docker/.examples/supervisor/fpm/docker-compose.yml delete mode 100644 scripts/docker/.examples/supervisor/fpm/web/Dockerfile delete mode 100644 scripts/docker/.examples/supervisor/fpm/web/nginx.conf delete mode 100644 scripts/docker/.examples/supervisor/php-apache/app/Dockerfile delete mode 100644 scripts/docker/.examples/supervisor/php-apache/app/supervisord.conf delete mode 100644 scripts/docker/.examples/supervisor/php-apache/docker-compose.yml delete mode 100644 scripts/docker/apache/Dockerfile delete mode 100644 scripts/docker/fpm/Dockerfile delete mode 100644 scripts/docker/php-apache/Dockerfile delete mode 100644 scripts/docker/php-apache/cron.sh diff --git a/.azure/azure.sig b/.azure/azure.sig index 13dad0f9a..79cb28d10 100644 --- a/.azure/azure.sig +++ b/.azure/azure.sig @@ -1,16 +1,16 @@ -----BEGIN PGP SIGNATURE----- -iQIzBAABCgAdFiEEuNgCced4O/05ANeg4OezJU6ORAcFAl9EuPkACgkQ4OezJU6O -RAcSSA/+OfGKqZSrpg/kF+aXB5qLqrgKtIxxxPKWf7OjXBIVfmrAs8gtiu7pyoLg -LC3GpAmVlh9BY4NkuAJgq1su9LHY+7bRowupfCNOUXo0AAD7t7yxTHtt/w7A8uAH -3gmeWQqo+AGuAepcT8eRJ8DxtMvT++MAGibeSE4ZrQ/Se19m22dTxrj5byKZceyW -vzPfIt+AozRbEDBubQvSPMl3ZTdWrlRbt+Gk1aLzUu5vFqrbF7eaGoYkdOpRbOvg -mljSy8DaFeFCf8mwGk4IHRxlcqNN7y/2ns4CSGzYtFAMSzSO4C0ktycrEYhCx6fG -JMs51q7QhoIw+USUgTw8v1oDxm9EsgY3W1YV8vC4I8HOlqcQmRIBzA9mNtP29hcT -dKBJT2ypuYN7qDQRBUscGHXCg4TnfLZMJfDYt+HbciVJtB49iwcWW56XJlriRFsk -tl7k1JwYUzqYoDkFxX1OOKg84cZ/37ifxm8yGWGbyWEJqunUdUBmDQYm5gLVhcHF -ueyQx4thmhQfwjk9NGeb2k1T/CWrVH2f9DGptNJpxN0L7R88GwE4Rf1FsG3gRXJo -9hBZ2rDgvz8yUpZuMQ15Tdt23ZDa8Bl625VLTPTWu5r7VHzGNmq9f0Jg0A/djcAc -Gv9lHzAjzPDi+WmKzAqepiPXCmfznaKE5zz3Hov207c/uYPqkxI= -=GLcU +iQIzBAABCgAdFiEEuNgCced4O/05ANeg4OezJU6ORAcFAl9RX/wACgkQ4OezJU6O +RAdt8xAAkFegPbLOS7hu9Y+JVmeiYulEYh+oPJv3gwg8uQmuGZm52djPcMQMRLzT +p33Lduqoz/55X3SNHcji8evdpvj02E0wlEGKlt5TOfSx2UxtVfw+VShI0h7W0Sov +lsXCVXTDpmtTeoQ9AB1eMcqUwYwrOIabOEWjqhkYc4Z18bH08t1AFWi1qJBhv1Lj +xGlioLztYUTIaSzhZ61wTtFkW7SkpJxDN7YIQMP6y6ie2bh1pM+pToQPHAfcTdba +uCjGyz5QojZ6O9JAIdWwjLIJC4vU9LEixt6gtrcQvO7JropcM7jH4dpOsq2e48cr +59EZxXo/LOBcgiT//we9qEYVGI2HOREKCWOt1sS1zVSjTRTUd1xfr6UpPjUPdSvG +5RioynlAsLo9RiCLtqygv/boQpTVx62LPCZcBamy0OI0EwUCFmj8NB6jLVgmYpjV +N1ILHFacz+dPXfxGUyBWUzPZ6bpfQZi1lm9UWPo7RYikqoSWdYkFMm158mTcOBWH +o85OaQEUswDGufnUYeHKXptvXU6gHoAnh/yf5b4Epc9QQkJ/crRtstmhMgHAjZBk +WTi53MoXwPthtz5XfNNl0VYZRmrpygFAguK55DdacNblRGNUWGzIFTv+nQmMJLye +4Ycj3OVWrCd5fhJbUVaEsVqlPDWEM716m+l0yRmvt6eKpJ/E0kQ= +=Sder -----END PGP SIGNATURE----- diff --git a/.azure/step-docker-build.yml b/.azure/step-docker-build.yml deleted file mode 100644 index 41e661320..000000000 --- a/.azure/step-docker-build.yml +++ /dev/null @@ -1,11 +0,0 @@ -steps: -- script: docker-compose --version - displayName: Check docker-composer version - -- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: - - script: make docker_build_master - displayName: Make docker image - -- ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: - - script: make docker_build - displayName: Make docker image diff --git a/.azure/step-docker-push-github.yml b/.azure/step-docker-push-github.yml deleted file mode 100644 index b4a52555f..000000000 --- a/.azure/step-docker-push-github.yml +++ /dev/null @@ -1,9 +0,0 @@ -steps: -- task: Docker@2 - displayName: Login to docker - inputs: - command: login - containerRegistry: docker-github - -- script: make docker_push_github - displayName: Publish docker image diff --git a/.azure/step-docker-push.yml b/.azure/step-docker-push.yml deleted file mode 100644 index 1b3f9b33c..000000000 --- a/.azure/step-docker-push.yml +++ /dev/null @@ -1,19 +0,0 @@ -steps: -- task: Docker@2 - displayName: Login to docker - inputs: - command: login - containerRegistry: docker-hub - -- script: make docker_tag - displayName: Tag docker image - -- script: make docker_push - displayName: Push docker image - -# notify microbadger to update -# https://microbadger.com/images/monicahq/monicahq -- script: curl -X POST $(MICROBADGER_WEBHOOK) - displayName: Notify microbadger - env: - MICROBADGER_WEBHOOK: $(MICROBADGER_WEBHOOK) diff --git a/Dockerfile b/Dockerfile deleted file mode 120000 index b021e899f..000000000 --- a/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -scripts/docker/apache/Dockerfile \ No newline at end of file diff --git a/Makefile b/Makefile index 86624a24c..338f32ace 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,6 @@ 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 @@ -77,93 +76,6 @@ all: $(MAKE) build $(MAKE) dist -docker: - $(MAKE) docker_build - $(MAKE) docker_tag - $(MAKE) docker_push - -docker_build: docker_build_apache docker_build_fpm docker_build_php_apache -docker_build_master: docker_build_apache docker_build_fpm - -docker_build_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/apache/Dockerfile \ - -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=$(BUILD_DATE) \ - --build-arg VCS_REF=$(GIT_REF) \ - --build-arg COMMIT=$(GIT_COMMIT) \ - --build-arg VERSION=$(BUILD) \ - -f scripts/docker/fpm/Dockerfile \ - -t $(DOCKER_IMAGE):fpm . - docker images - -DOCKER_SQUASH := $(shell which docker-squash) -ifeq ($(DOCKER_SQUASH),) - DOCKER_SQUASH := ~/.local/bin/docker-squash -endif - -docker_squash: - $(DOCKER_SQUASH) -f $(shell docker image ls -q `head -n 1 scripts/docker/apache/Dockerfile | cut -d ' ' -f 2`) -t $(DOCKER_IMAGE):latest $(DOCKER_IMAGE):latest - $(DOCKER_SQUASH) -f $(shell docker image ls -q `head -n 1 scripts/docker/fpm/Dockerfile | cut -d ' ' -f 2`) -t $(DOCKER_IMAGE):fpm $(DOCKER_IMAGE):fpm - docker images - -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):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_github: docker_push_github_apache docker_push_github_fpm - -docker_push_github_apache: - docker tag $(DOCKER_IMAGE) docker.pkg.github.com/monicahq/monica/monica:$(BUILD) - docker push docker.pkg.github.com/monicahq/monica/monica:$(BUILD) - -docker_push_github_fpm: - docker tag $(DOCKER_IMAGE):fpm docker.pkg.github.com/monicahq/monica/monica:$(BUILD)-fpm - docker push docker.pkg.github.com/monicahq/monica/monica:$(BUILD)-fpm - -.PHONY: docker docker_build docker_build_master docker_build_apache docker_build_fpm docker_build_php_apache docker_tag -.PHONY: docker_push_github docker_push_github_apache docker_push_github_fpm - build: composer install --no-interaction --no-suggest --ignore-platform-reqs php artisan lang:generate diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3b4354886..ef308c673 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -57,19 +57,3 @@ stages: parameters: no_dev: true - template: .azure/step-deploy-dist.yml - - - ${{ if or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) }}: - - deployment: deploy_docker - pool: - vmImage: 'ubuntu-latest' - environment: 'monica' - strategy: - runOnce: - deploy: - steps: - - download: none - - checkout: self - - template: .azure/step-docker-build.yml - - template: .azure/step-docker-push-github.yml - - ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}: - - template: .azure/step-docker-push.yml diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 09f696cb4..000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: "3.4" - -services: - monicahq: - build: . - image: monicahq/monicahq - depends_on: - - mysql - ports: - - 80:80 - env_file: .env - volumes: - - data:/var/www/monica/storage - restart: always - - mysql: - image: mysql:5.7 - environment: - - MYSQL_ROOT_PASSWORD=sekret_root_password - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - mysql: - name: mysql diff --git a/docs/installation/docker-mysql.md b/docs/installation/docker-mysql.md deleted file mode 100644 index cec7122fb..000000000 --- a/docs/installation/docker-mysql.md +++ /dev/null @@ -1,35 +0,0 @@ -# Connect to MySQL inside of a Docker container - -There may come a time when developing or managing a Monica instance that you -would like to connect directly to the MySQL database being used. - -For example you may want to -- alter test data -- generate custom metrics -- ... - ---- - -1. Stop your Monica and MySQL containers if they are running -1. Bind port 3306 in your container to 3306 on your host machine - 1. Add `EXPOSE 3306:3306` to your `Dockerfile` under `EXPOSE 80:80` - 1. Add a `ports` node under `mysql` in `docker-compose.yml` with a `3306:3306` entry -1. Start your containers with `docker-compose up`, wait for them to spin up -1. Connect to the database via a MySQL client (CLI, GUI, etc.) - ---- - -## Sequel Pro (macOS) - -You can install Sequel Pro from [the website](http://www.sequelpro.com/) or via -`brew cask install sequel-pro` if you have homebrew cask installed. - -Connect to the database using the information in your `.env` file. -In this example image we are using the default values. - -![SequelProConnecting](https://user-images.githubusercontent.com/25419741/38381051-e8e0b184-3905-11e8-85ce-3122beb83513.png) - - -If that is successful you are now connected and can execute queries, look at schemas, etc. - -![SequelProConnected](https://user-images.githubusercontent.com/25419741/38381084-fbe6b008-3905-11e8-8c1c-d2a29c2d5e7e.png) diff --git a/docs/installation/providers/docker.md b/docs/installation/providers/docker.md index 4ce962893..f82381ca8 100644 --- a/docs/installation/providers/docker.md +++ b/docs/installation/providers/docker.md @@ -6,258 +6,39 @@ Monica can run with Docker images. - [Prerequisites](#prerequisites) - [Use Monica docker image](#use-monica-docker-image) - - [Using the apache image](#using-the-apache-image) - - [Using the fpm image](#using-the-fpm-image) - - [Persistent data storage](#persistent-data-storage) - - [Run commands inside the container](#run-commands-inside-the-container) - [Running the image with docker-compose](#running-the-image-with-docker-compose) - - [Apache version](#apache-version) - - [FPM version](#fpm-version) -- [Make Monica available from the internet](#make-monica-available-from-the-internet) - - [Using a proxy webserver on the host](#using-a-proxy-webserver-on-the-host) - - [Using a proxy webserver container](#using-a-proxy-webserver-container) -- [Other documents to read](#other-documents-to-read) ## Prerequisites -You can use [Docker](https://www.docker.com) and -[docker-compose](https://docs.docker.com/compose/) to pull or build +You can use [Docker](https://www.docker.com) and [docker-compose](https://docs.docker.com/compose/) to pull or build and run a Monica image, complete with a self-contained MySQL database. -This has the nice properties that you don't have to install lots of -software directly onto your system, and you can be up and running +This has the nice properties that you don't have to install lots of software directly onto your system, and you can be up and running quickly with a known working environment. For any help about how to install Docker, see their [documentation](https://docs.docker.com/install/) ## Use Monica docker image -There are two versions of the image you may choose from. +The [standard `monica` image](https://hub.docker.com/_/monica/) can be run with the latest release of Monica. -The `apache` tag contains a full Monica installation with an apache webserver. This points to the default `latest` tag too. - -The `fpm` tag contains a fastCGI-Process that serves the web pages. This image should be combined with a webserver used as a proxy, like apache or nginx. - -### Using the apache image - -This image contains a webserver that exposes port 80. Run the container with: -```sh -docker run -d -p 8080:80 monicahq/monicahq -``` - -### Using the fpm image - -This image serves a fastCGI server that exposes port 9000. You may need an additional web server that can proxy requests to the fpm port 9000 of the container. -Run this container with: -```sh -docker run -d -p 9000:9000 monicahq/monicahq:fpm -``` - -### Persistent data storage - -To have a persistent storage for your datas, you may want to create volumes for your db, and for monica you will have to save the `/var/www/monica/storage` directory. - -Run a container with this named volume: -```sh -docker run -d \ - -v monica_data:/var/www/monica/storage \ - monicahq/monicahq -``` - -### Run commands inside the container - -Like every Laravel application, the `php artisan` command is very usefull for Monica. -To run a command inside the container, run +Run the container with: ```sh -docker exec CONTAINER_ID php artisan COMMAND +mysqlCid="$(docker run -d \ + -e MYSQL_RANDOM_ROOT_PASSWORD=true \ + -e MYSQL_DATABASE=monica \ + -e MYSQL_USER=homestead \ + -e MYSQL_PASSWORD=secret \ + "mysql:5.7")" +docker run -d \ + --link "$mysqlCid":mysql \ + -e DB_HOST=mysql \ + -p 8080:80 \ + monica ``` -or for docker-compose -```sh -docker-compose exec monicahq php artisan COMMAND -``` -where `monicahq` is the name of the service in your `docker-compose.yml` file. - +Wait for the migration db to complete, then go to [http://localhost:8080](http://localhost:8080). ## Running the image with docker-compose -See some examples of docker-compose possibilities in the [example section](/scripts/docker/.examples). - ---- - -### Apache version - -This version will use the apache image and add a mysql container. The volumes are set to keep your data persistent. This setup provides **no ssl encryption** and is intended to run behind a proxy. - -Make sure to pass in values for `APP_KEY` variable before you run this setup. - -Set `APP_KEY` to a random 32-character string. For example, if you -have the `pwgen` utility installed, you could copy and paste the -output of `pwgen -s 32 1`. - -1. Create a `docker-compose.yml` file - -```yaml -version: "3.4" - -services: - app: - image: monicahq/monicahq - depends_on: - - db - ports: - - 8080:80 - environment: - # generate with `pwgen -s 32 1` for instance: - - APP_KEY= - - DB_HOST=db - volumes: - - data:/var/www/monica/storage - restart: always - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - mysql: - name: mysql -``` - -2. Set a value for `APP_KEY` variable before you run this setup. - - It should be a random 32-character string. For example, if you have the `pwgen` utility installed, - you can copy and paste the output of - ```sh - pwgen -s 32 1 - ``` - -3. Run - ```sh - docker-compose up -d - ``` - - Wait until all migrations are done and then access Monica at http://localhost:8080/ from your host system. - If this looks ok, add your first user account. - -4. Run this command once: - ```sh - docker-compose exec app php artisan setup:production - ``` - - -### FPM version - -When using FPM image, you will need another container with a webserver to proxy http requests. In this example we use nginx with a basic container to do this. - -The webserver will need an access to all static files from Monica container, the volumes `html` will deal with it. - - -1. Download `nginx.conf` file. An example can be found on the [`example section`](/scripts/docker/.examples/supervisor/fpm/web/nginx.conf) - ```sh - curl -sSL https://raw.githubusercontent.com/monicahq/monica/master/scripts/docker/.examples/supervisor/fpm/web/nginx.conf -o nginx.conf - ``` - -2. Create a `docker-compose.yml` file - -```yaml -version: "3.4" - -services: - app: - image: monicahq/monicahq:fpm - depends_on: - - db - environment: - # generate with `pwgen -s 32 1` for instance: - - APP_KEY= - - DB_HOST=db - volumes: - - html:/var/www/monica - - data:/var/www/monica/storage - restart: always - - web: - image: nginx - ports: - - 8080:80 - depends_on: - - app - volumes: - # see [`nginx.conf`](/scripts/docker/.examples/supervisor/fpm/web/nginx.conf) - - ./nginx.conf:/etc/nginx/nginx.conf:ro - - html:/var/www/monica:ro - - data:/var/www/monica/storage:ro - restart: always - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - html: - name: html - mysql: - name: mysql -``` - -3. Set a value for `APP_KEY` variable before you run this setup. - - It should be a random 32-character string. For example, if you have the `pwgen` utility installed, - you can copy and paste the output of - ```sh - pwgen -s 32 1 - ``` - -4. Run - ```sh - docker-compose up -d - ``` - - Wait until all migrations are done and then access Monica at http://localhost:8080/ from your host system. - If this looks ok, add your first user account. - -5. Run this command once: - ```sh - docker-compose exec app php artisan setup:production - ``` - - -## Make Monica available from the internet - -To expose your Monica instance for the internet, it's important to set `APP_ENV=production` in your `.env` file or environment variables. In this case `https` scheme will be **mandatory**. - -### Using a proxy webserver on the host - -One way to expose your Monica instance is to use a proxy webserver from your host with SSL capabilities. This is possible with a reverse proxy. - -See [this documentation](/docs/installation/ssl.md) about howto set a ssl reverse proxy. - -### Using a proxy webserver container - -See some examples of docker-compose possibilities in the [example section](/scripts/docker/.examples) to show how to a proxy webserver with ssl capabilities. - - - -## Other documents to read - -- [Build your own docker image](/docs/contribute/docker.md) -- [Connecting to MySQL inside of a Docker container](/docs/installation/docker-mysql.md) +See some examples of docker-compose possibilities in the [example section](https://github.com/monicahq/docker/tree/master/.examples). diff --git a/docs/installation/ssl.md b/docs/installation/ssl.md index 75fda6e4a..9894bdfb5 100644 --- a/docs/installation/ssl.md +++ b/docs/installation/ssl.md @@ -124,11 +124,11 @@ And a `docker-compose.yml` like: version: '3.4' services: monica: - image: monicahq/monicahq + image: monica expose: - 3001:80 volumes: - - '/var/monica-storage:/var/www/monica/storage' + - '/var/monica-storage:/var/www/html/storage' env_file: /etc/monica/monica.env restart: unless-stopped diff --git a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml b/scripts/docker/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml deleted file mode 100644 index e2772ba78..000000000 --- a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml +++ /dev/null @@ -1,121 +0,0 @@ -# Run Monica with a self-signed-ssl certificate -# -# You might want to set these variables in you .env file: -# -#- APP_ENV=production -#- APP_URL with your domain (https scheme) -#- APP_TRUSTED_PROXIES=* -# -#- DB_HOST=db -# See `db` container for these values: -#- DB_DATABASE=monica -#- DB_USERNAME=homestead -#- DB_PASSWORD=secret -# -# To use redis: -#- REDIS_HOST=redis -#- CACHE_DRIVER=redis -#- QUEUE_DRIVER=redis -# - -version: "3.4" - -services: - app: - image: monicahq/monicahq:fpm - env_file: .env - volumes: - - data:/var/www/monica/storage - restart: always - depends_on: - - db - - redis - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - db:/var/lib/mysql - restart: always - - redis: - image: redis:alpine - restart: always - - cron: - image: monicahq/monicahq:fpm - env_file: .env - restart: always - volumes: - - data:/var/www/monica/storage - command: cron.sh - depends_on: - - db - - redis - - queue: - image: monicahq/monicahq:fpm - env_file: .env - restart: always - volumes: - - data:/var/www/monica/storage - command: queue.sh - depends_on: - - db - - redis - - web: - build: ./web - restart: always - environment: - - VIRTUAL_HOST=monica.local - volumes: - - data:/var/www/monica/storage:ro - depends_on: - - app - networks: - - proxy-tier - - default - - proxy: - build: ./proxy - restart: always - ports: - - 80:80 - - 443:443 - volumes: - - certs:/etc/nginx/certs:ro - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - proxy-tier - depends_on: - - omgwtfssl - - omgwtfssl: - image: paulczar/omgwtfssl - restart: "no" - volumes: - - certs:/certs - environment: - - SSL_SUBJECT=monica.local - - CA_SUBJECT=my@example.com - - SSL_KEY=/certs/monica.local.key - - SSL_CSR=/certs/monica.local.csr - - SSL_CERT=/certs/monica.local.crt - networks: - - proxy-tier - -volumes: - data: - name: data - db: - name: db - certs: - name: certs - -networks: - proxy-tier: diff --git a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/Dockerfile b/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/Dockerfile deleted file mode 100644 index 58fd3714a..000000000 --- a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM jwilder/nginx-proxy:alpine - -COPY vhost.conf /etc/nginx/vhost.d/default diff --git a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/vhost.conf b/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/vhost.conf deleted file mode 100644 index f64079738..000000000 --- a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/proxy/vhost.conf +++ /dev/null @@ -1,2 +0,0 @@ -client_max_body_size 10G; -server_tokens off; \ No newline at end of file diff --git a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/Dockerfile b/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/Dockerfile deleted file mode 100644 index 3de42749d..000000000 --- a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM monicahq/monicahq:fpm AS monica - -FROM nginx:alpine - -COPY nginx.conf /etc/nginx/nginx.conf - -# Copy content of monica image -COPY --from=monica /var/www/monica /var/www/monica -RUN ln -sf /var/www/monica/storage/app/public /var/www/monica/public/storage diff --git a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/nginx.conf b/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/nginx.conf deleted file mode 100644 index f1b8ec088..000000000 --- a/scripts/docker/.examples/nginx-proxy-self-signed-ssl/web/nginx.conf +++ /dev/null @@ -1,161 +0,0 @@ -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - set_real_ip_from 10.0.0.0/8; - set_real_ip_from 172.16.0.0/12; - set_real_ip_from 192.168.0.0/16; - real_ip_header X-Real-IP; - - # Connect to app service - upstream php-handler { - server app:9000; - } - - server { - listen 80; - - server_name monica; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Remove X-Powered-By, which is an information leak - fastcgi_hide_header X-Powered-By; - - root /var/www/monica/public; - - index index.html index.htm index.php; - - charset utf-8; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ ^/(?:robots.txt|security.txt) { - allow all; - log_not_found off; - access_log off; - } - - error_page 404 500 502 503 504 /index.php; - - location ~ /\.well-known/(?:carddav|caldav) { - return 301 $scheme://$host/dav; - } - location = /.well-known/security.txt { - return 301 $scheme://$host/security.txt; - } - location ~ /\.(?!well-known).* { - deny all; - } - - # set max upload size - client_max_body_size 10G; - fastcgi_buffers 64 4K; - - # Enable gzip but do not remove ETag headers - gzip on; - gzip_vary on; - gzip_comp_level 4; - gzip_min_length 256; - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; - gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - - # Uncomment if your server is build with the ngx_pagespeed module - # This module is currently not supported. - #pagespeed off; - - location ~ \.php$ { - # regex to split $uri to $fastcgi_script_name and $fastcgi_path - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - - # Check that the PHP script exists before passing it - try_files $fastcgi_script_name =404; - - fastcgi_pass php-handler; - fastcgi_index index.php; - - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # Bypass the fact that try_files resets $fastcgi_path_info - # see: http://trac.nginx.org/nginx/ticket/321 - set $path_info $fastcgi_path_info; - fastcgi_param PATH_INFO $path_info; - } - - # Adding the cache control header for js and css files - # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff2?|svg|gif|json)$ { - try_files $uri /index.php$request_uri; - add_header Cache-Control "public, max-age=15778463"; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # Note it is intended to have those duplicated to the ones above. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Optional: Don't log access to assets - access_log off; - } - - location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { - try_files $uri /index.php$request_uri; - - # Optional: Don't log access to assets - access_log off; - } - - # deny access to .htaccess files - location ~ /\.ht { - deny all; - } - } -} diff --git a/scripts/docker/.examples/nginx-proxy/docker-compose.yml b/scripts/docker/.examples/nginx-proxy/docker-compose.yml deleted file mode 100644 index f25cff064..000000000 --- a/scripts/docker/.examples/nginx-proxy/docker-compose.yml +++ /dev/null @@ -1,127 +0,0 @@ -# Run Monica with Let's Encrypt certificate -# -# You might want to set these variables in you .env file: -# -#- APP_ENV=production -#- APP_URL with your domain (https scheme) -# -#- DB_HOST=db -# See `db` container for these values: -#- DB_DATABASE=monica -#- DB_USERNAME=homestead -#- DB_PASSWORD=secret -# -# To use redis: -#- REDIS_HOST=redis -#- CACHE_DRIVER=redis -#- QUEUE_CONNECTION=redis -# - -version: "3.4" - -services: - app: - image: monicahq/monicahq:fpm - env_file: .env - volumes: - - data:/var/www/monica/storage - restart: always - depends_on: - - db - - redis - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - - redis: - image: redis:alpine - restart: always - - cron: - image: monicahq/monicahq:fpm - env_file: .env - restart: always - volumes: - - data:/var/www/monica/storage - command: cron.sh - depends_on: - - db - - redis - - queue: - image: monicahq/monicahq:fpm - env_file: .env - restart: always - volumes: - - data:/var/www/monica/storage - command: queue.sh - depends_on: - - db - - redis - - web: - build: ./web - restart: always - environment: - - VIRTUAL_HOST= - - LETSENCRYPT_HOST= - - LETSENCRYPT_EMAIL= - volumes: - - data:/var/www/monica/storage:ro - depends_on: - - app - networks: - - proxy-tier - - default - - proxy: - build: ./proxy - restart: always - ports: - - 80:80 - - 443:443 - labels: - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" - volumes: - - certs:/etc/nginx/certs:ro - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - proxy-tier - - letsencrypt-companion: - image: jrcs/letsencrypt-nginx-proxy-companion - restart: always - volumes: - - certs:/etc/nginx/certs - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - /var/run/docker.sock:/var/run/docker.sock:ro - networks: - - proxy-tier - depends_on: - - proxy - -volumes: - data: - name: data - mysql: - name: mysql - certs: - name: certs - vhost.d: - name: vhost.d - html: - name: html - -networks: - proxy-tier: diff --git a/scripts/docker/.examples/nginx-proxy/proxy/Dockerfile b/scripts/docker/.examples/nginx-proxy/proxy/Dockerfile deleted file mode 100644 index 58fd3714a..000000000 --- a/scripts/docker/.examples/nginx-proxy/proxy/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM jwilder/nginx-proxy:alpine - -COPY vhost.conf /etc/nginx/vhost.d/default diff --git a/scripts/docker/.examples/nginx-proxy/proxy/vhost.conf b/scripts/docker/.examples/nginx-proxy/proxy/vhost.conf deleted file mode 100644 index f64079738..000000000 --- a/scripts/docker/.examples/nginx-proxy/proxy/vhost.conf +++ /dev/null @@ -1,2 +0,0 @@ -client_max_body_size 10G; -server_tokens off; \ No newline at end of file diff --git a/scripts/docker/.examples/nginx-proxy/web/Dockerfile b/scripts/docker/.examples/nginx-proxy/web/Dockerfile deleted file mode 100644 index 3de42749d..000000000 --- a/scripts/docker/.examples/nginx-proxy/web/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM monicahq/monicahq:fpm AS monica - -FROM nginx:alpine - -COPY nginx.conf /etc/nginx/nginx.conf - -# Copy content of monica image -COPY --from=monica /var/www/monica /var/www/monica -RUN ln -sf /var/www/monica/storage/app/public /var/www/monica/public/storage diff --git a/scripts/docker/.examples/nginx-proxy/web/nginx.conf b/scripts/docker/.examples/nginx-proxy/web/nginx.conf deleted file mode 100644 index f1b8ec088..000000000 --- a/scripts/docker/.examples/nginx-proxy/web/nginx.conf +++ /dev/null @@ -1,161 +0,0 @@ -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - set_real_ip_from 10.0.0.0/8; - set_real_ip_from 172.16.0.0/12; - set_real_ip_from 192.168.0.0/16; - real_ip_header X-Real-IP; - - # Connect to app service - upstream php-handler { - server app:9000; - } - - server { - listen 80; - - server_name monica; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Remove X-Powered-By, which is an information leak - fastcgi_hide_header X-Powered-By; - - root /var/www/monica/public; - - index index.html index.htm index.php; - - charset utf-8; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ ^/(?:robots.txt|security.txt) { - allow all; - log_not_found off; - access_log off; - } - - error_page 404 500 502 503 504 /index.php; - - location ~ /\.well-known/(?:carddav|caldav) { - return 301 $scheme://$host/dav; - } - location = /.well-known/security.txt { - return 301 $scheme://$host/security.txt; - } - location ~ /\.(?!well-known).* { - deny all; - } - - # set max upload size - client_max_body_size 10G; - fastcgi_buffers 64 4K; - - # Enable gzip but do not remove ETag headers - gzip on; - gzip_vary on; - gzip_comp_level 4; - gzip_min_length 256; - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; - gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - - # Uncomment if your server is build with the ngx_pagespeed module - # This module is currently not supported. - #pagespeed off; - - location ~ \.php$ { - # regex to split $uri to $fastcgi_script_name and $fastcgi_path - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - - # Check that the PHP script exists before passing it - try_files $fastcgi_script_name =404; - - fastcgi_pass php-handler; - fastcgi_index index.php; - - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # Bypass the fact that try_files resets $fastcgi_path_info - # see: http://trac.nginx.org/nginx/ticket/321 - set $path_info $fastcgi_path_info; - fastcgi_param PATH_INFO $path_info; - } - - # Adding the cache control header for js and css files - # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff2?|svg|gif|json)$ { - try_files $uri /index.php$request_uri; - add_header Cache-Control "public, max-age=15778463"; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # Note it is intended to have those duplicated to the ones above. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Optional: Don't log access to assets - access_log off; - } - - location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { - try_files $uri /index.php$request_uri; - - # Optional: Don't log access to assets - access_log off; - } - - # deny access to .htaccess files - location ~ /\.ht { - deny all; - } - } -} diff --git a/scripts/docker/.examples/readme.md b/scripts/docker/.examples/readme.md deleted file mode 100644 index ae26ad808..000000000 --- a/scripts/docker/.examples/readme.md +++ /dev/null @@ -1,65 +0,0 @@ -# Docker examples for Monica - -In this section you will find some examples about how to use monica's docker images. - -Example|Description --------|----------- -[`supervisor`](supervisor)| uses supervisor to run a cron and a queue inside your container. -[`nginx-proxy-self-signed-ssl`](nginx-proxy-self-signed-ssl)| shows you how to run monica with a self signed ssl certificate. -[`nginx-proxy`](nginx-proxy)| shows you how to run monica with https and generate a [Let's Encrypt](https://letsencrypt.org/) certificate. - - -## Run with docker-compose - -### Configuration (all versions) - -First, download a copy of Monica example configuration file: - -```sh -curl -sS https://raw.githubusercontent.com/monicahq/monica/master/.env.example -o .env -``` - -Open the file in an editor and update it for your own needs: - -- Set `APP_KEY` to a random 32-character string. For example, if you - have the `pwgen` utility installed, you could copy and paste the - output of `pwgen -s 32 1`. -- Edit the `MAIL_*` settings to point to your own [mailserver](/docs/installation/mail.md). -- Set `DB_*` settings to point to your database configuration. If you don't want to set a db prefix, be careful to set `DB_PREFIX=` and not `DB_PREFIX=''` as docker will not expand this as an empty string. -- Set `DB_HOST=db` or any name of the database container you will link to. - - -### With supervisor - -The [`supervisor`](supervisor) examples shows you how to run monica with -- a db container (mysql:5.7) -- an app container, which run `supervisord` to handle a web server/fpm, a cron, and a queue. - -This let you use `QUEUE_CONNECTION=database` in your `.env` file. - - -### With nginx proxy and a self-signed certificate - -[`nginx-proxy-self-signed-ssl`](nginx-proxy-self-signed-ssl) example shows you how to run monica with a self signed ssl certificate, to run the application in `https` mode. - -Set `VIRTUAL_HOST` and `SSL_SUBJECT` with the right domain name, and update `SSL_KEY`, `SSL_CSR`, and `SSL_CERT` accordingly. -This example generates a new self-signed certificate. - -Your browser might warn you about security issue, as a self-signed certificate is not trusted in production mode. For a real domain certificate, see the next section. - - -### With nginx proxy and a Let's Encrypt certificate - -[`nginx-proxy`](nginx-proxy) example shows you how to run monica and generate a [Let's Encrypt](https://letsencrypt.org/) certificate for your domain. - -Don't forget to set: -- `VIRTUAL_HOST` and `LETSENCRYPT_HOST` with your domain -- `LETSENCRYPT_EMAIL` with a valid email -- `APP_URL` in your `.env` file with the right domain url - -You may want to set `APP_ENV=production` to force the use of `https` scheme. - -This example add a `redis` container, that can be used too, adding these variables to your `.env` file: -- `REDIS_HOST=redis`: mandatory -- `CACHE_DRIVER=redis`: to use redis as a cache table -- `QUEUE_CONNECTION=redis`: to use redis as a queue table diff --git a/scripts/docker/.examples/supervisor/apache/app/Dockerfile b/scripts/docker/.examples/supervisor/apache/app/Dockerfile deleted file mode 100644 index b96b60930..000000000 --- a/scripts/docker/.examples/supervisor/apache/app/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM monicahq/monicahq:apache - -COPY supervisord.conf /etc/supervisord.conf -CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/scripts/docker/.examples/supervisor/apache/app/supervisord.conf b/scripts/docker/.examples/supervisor/apache/app/supervisord.conf deleted file mode 100644 index e1902a234..000000000 --- a/scripts/docker/.examples/supervisor/apache/app/supervisord.conf +++ /dev/null @@ -1,30 +0,0 @@ -[supervisord] -nodaemon=true -user=root - -[program:cron] -command=/usr/sbin/crond -f -l 0 -autostart=true -autorestart=true - -[program:queue] -process_name=%(program_name)s_%(process_num)02d -command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration -numprocs=1 -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true -startretries=0 - -[program:httpd] -process_name=%(program_name)s_%(process_num)02d -command=/usr/local/bin/apache2-foreground -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/scripts/docker/.examples/supervisor/apache/docker-compose.yml b/scripts/docker/.examples/supervisor/apache/docker-compose.yml deleted file mode 100644 index f053c1eea..000000000 --- a/scripts/docker/.examples/supervisor/apache/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.4" - -services: - app: - build: ./app - depends_on: - - db - env_file: .env - ports: - - 80:80 - volumes: - - data:/var/www/monica/storage - restart: always - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - mysql: - name: mysql diff --git a/scripts/docker/.examples/supervisor/fpm/app/Dockerfile b/scripts/docker/.examples/supervisor/fpm/app/Dockerfile deleted file mode 100644 index 3a6571a4b..000000000 --- a/scripts/docker/.examples/supervisor/fpm/app/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM monicahq/monicahq:fpm - -COPY supervisord.conf /etc/supervisord.conf -CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/scripts/docker/.examples/supervisor/fpm/app/supervisord.conf b/scripts/docker/.examples/supervisor/fpm/app/supervisord.conf deleted file mode 100644 index 563fd3f74..000000000 --- a/scripts/docker/.examples/supervisor/fpm/app/supervisord.conf +++ /dev/null @@ -1,30 +0,0 @@ -[supervisord] -nodaemon=true -user=root - -[program:cron] -command=/usr/sbin/crond -f -l 0 -autostart=true -autorestart=true - -[program:queue] -process_name=%(program_name)s_%(process_num)02d -command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration -numprocs=1 -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true -startretries=0 - -[program:fpm] -process_name=%(program_name)s_%(process_num)02d -command=/usr/sbin/php-fpm7 -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/scripts/docker/.examples/supervisor/fpm/docker-compose.yml b/scripts/docker/.examples/supervisor/fpm/docker-compose.yml deleted file mode 100644 index 6017cf749..000000000 --- a/scripts/docker/.examples/supervisor/fpm/docker-compose.yml +++ /dev/null @@ -1,38 +0,0 @@ -version: "3.4" - -services: - app: - build: ./app - depends_on: - - db - env_file: .env - volumes: - - data:/var/www/monica/storage - restart: always - - web: - build: ./web - restart: always - ports: - - 80:80 - volumes: - - data:/var/www/monica/storage:ro - depends_on: - - app - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - mysql: - name: mysql diff --git a/scripts/docker/.examples/supervisor/fpm/web/Dockerfile b/scripts/docker/.examples/supervisor/fpm/web/Dockerfile deleted file mode 100644 index 3de42749d..000000000 --- a/scripts/docker/.examples/supervisor/fpm/web/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM monicahq/monicahq:fpm AS monica - -FROM nginx:alpine - -COPY nginx.conf /etc/nginx/nginx.conf - -# Copy content of monica image -COPY --from=monica /var/www/monica /var/www/monica -RUN ln -sf /var/www/monica/storage/app/public /var/www/monica/public/storage diff --git a/scripts/docker/.examples/supervisor/fpm/web/nginx.conf b/scripts/docker/.examples/supervisor/fpm/web/nginx.conf deleted file mode 100644 index f1b8ec088..000000000 --- a/scripts/docker/.examples/supervisor/fpm/web/nginx.conf +++ /dev/null @@ -1,161 +0,0 @@ -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - set_real_ip_from 10.0.0.0/8; - set_real_ip_from 172.16.0.0/12; - set_real_ip_from 192.168.0.0/16; - real_ip_header X-Real-IP; - - # Connect to app service - upstream php-handler { - server app:9000; - } - - server { - listen 80; - - server_name monica; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Remove X-Powered-By, which is an information leak - fastcgi_hide_header X-Powered-By; - - root /var/www/monica/public; - - index index.html index.htm index.php; - - charset utf-8; - - location / { - try_files $uri $uri/ /index.php?$query_string; - } - - location ~ ^/(?:robots.txt|security.txt) { - allow all; - log_not_found off; - access_log off; - } - - error_page 404 500 502 503 504 /index.php; - - location ~ /\.well-known/(?:carddav|caldav) { - return 301 $scheme://$host/dav; - } - location = /.well-known/security.txt { - return 301 $scheme://$host/security.txt; - } - location ~ /\.(?!well-known).* { - deny all; - } - - # set max upload size - client_max_body_size 10G; - fastcgi_buffers 64 4K; - - # Enable gzip but do not remove ETag headers - gzip on; - gzip_vary on; - gzip_comp_level 4; - gzip_min_length 256; - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; - gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - - # Uncomment if your server is build with the ngx_pagespeed module - # This module is currently not supported. - #pagespeed off; - - location ~ \.php$ { - # regex to split $uri to $fastcgi_script_name and $fastcgi_path - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - - # Check that the PHP script exists before passing it - try_files $fastcgi_script_name =404; - - fastcgi_pass php-handler; - fastcgi_index index.php; - - include fastcgi_params; - - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # Bypass the fact that try_files resets $fastcgi_path_info - # see: http://trac.nginx.org/nginx/ticket/321 - set $path_info $fastcgi_path_info; - fastcgi_param PATH_INFO $path_info; - } - - # Adding the cache control header for js and css files - # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff2?|svg|gif|json)$ { - try_files $uri /index.php$request_uri; - add_header Cache-Control "public, max-age=15778463"; - - ## HSTS ## - # Add the 'Strict-Transport-Security' headers to enable HSTS protocol. - # Note it is intended to have those duplicated to the ones above. - # WARNING: Only add the preload option once you read about the consequences: https://hstspreload.org/. - # This form will add the domain to a hardcoded list that is shipped in all major browsers and getting - # removed from this list could take several months. - # - #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload;" always; - - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Download-Options "noopen" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "none" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Optional: Don't log access to assets - access_log off; - } - - location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ { - try_files $uri /index.php$request_uri; - - # Optional: Don't log access to assets - access_log off; - } - - # deny access to .htaccess files - location ~ /\.ht { - deny all; - } - } -} diff --git a/scripts/docker/.examples/supervisor/php-apache/app/Dockerfile b/scripts/docker/.examples/supervisor/php-apache/app/Dockerfile deleted file mode 100644 index 6ea49087e..000000000 --- a/scripts/docker/.examples/supervisor/php-apache/app/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM monicahq/monicahq:php-apache - -COPY supervisord.conf /etc/supervisord.conf -CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/scripts/docker/.examples/supervisor/php-apache/app/supervisord.conf b/scripts/docker/.examples/supervisor/php-apache/app/supervisord.conf deleted file mode 100644 index 5944ac483..000000000 --- a/scripts/docker/.examples/supervisor/php-apache/app/supervisord.conf +++ /dev/null @@ -1,30 +0,0 @@ -[supervisord] -nodaemon=true -user=root - -[program:cron] -command=/usr/sbin/cron -f -L 0 -autostart=true -autorestart=true - -[program:queue] -process_name=%(program_name)s_%(process_num)02d -command=/usr/bin/php /var/www/monica/artisan queue:work --sleep=10 --timeout=0 --tries=3 --queue=default,migration -numprocs=1 -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true -startretries=0 - -[program:apache] -process_name=%(program_name)s_%(process_num)02d -command=/usr/local/bin/apache2-foreground -stdout_logfile=/proc/1/fd/1 -stdout_logfile_maxbytes=0 -stderr_logfile=/proc/1/fd/2 -stderr_logfile_maxbytes=0 -autostart=true -autorestart=true diff --git a/scripts/docker/.examples/supervisor/php-apache/docker-compose.yml b/scripts/docker/.examples/supervisor/php-apache/docker-compose.yml deleted file mode 100644 index f053c1eea..000000000 --- a/scripts/docker/.examples/supervisor/php-apache/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3.4" - -services: - app: - build: ./app - depends_on: - - db - env_file: .env - ports: - - 80:80 - volumes: - - data:/var/www/monica/storage - restart: always - - db: - image: mysql:5.7 - environment: - - MYSQL_RANDOM_ROOT_PASSWORD=true - - MYSQL_DATABASE=monica - - MYSQL_USER=homestead - - MYSQL_PASSWORD=secret - volumes: - - mysql:/var/lib/mysql - restart: always - -volumes: - data: - name: data - mysql: - name: mysql diff --git a/scripts/docker/apache/Dockerfile b/scripts/docker/apache/Dockerfile deleted file mode 100644 index a71040525..000000000 --- a/scripts/docker/apache/Dockerfile +++ /dev/null @@ -1,164 +0,0 @@ -FROM alpine:latest - -# 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 set -ex; \ - \ - apk update; \ - apk upgrade; \ - apk add --virtual .build-deps \ - curl openssl bash \ - ; \ - apk add supervisor netcat-openbsd rsync \ - #- base - php7 php7-intl php7-openssl php7-ctype \ - php7-zip php7-zlib php7-opcache \ - php7-redis \ - #- Authentication Guards - php7-session php7-tokenizer \ - #- laravel/cashier sabre/vobject sabre/xml - php7-dom \ - #- intervention/image - php7-fileinfo \ - #- laravel/cashier - php7-gd \ - #- composer - php7-phar php7-json php7-iconv \ - #- laravel/framework sabre/vobject - php7-mbstring \ - #- league/flysystem-aws-s3-v3 - php7-simplexml \ - #- sabre/vobject sabre/xml - php7-xml php7-xmlreader php7-xmlwriter \ - #- mysql - php7-mysqli php7-pdo_mysql \ - #- pgsql - php7-pgsql php7-pdo_pgsql \ - #- vinkla/hashids - php7-bcmath \ - #- sentry/sentry - php7-curl \ - #- cbor-php (webauthn) - php7-gmp \ - #- web-token/jwt-signature-algorithm-eddsa - php7-sodium \ - #- bacon/bacon-qr-code - php7-imagick - -# Create a user to own all the code and assets and give them a working -# directory -RUN set -ex; \ - \ - mkdir -p /var/www/monica; \ - grep -q apache /etc/group || addgroup -S apache; \ - adduser -D monica apache -h /var/www/monica -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 --chown=monica:monica \ - readme.md \ - CONTRIBUTING.md \ - CHANGELOG.md \ - CONTRIBUTORS \ - LICENSE \ - artisan \ - composer.json \ - composer.lock \ - ./ -COPY --chown=monica:monica app ./app -COPY --chown=monica:monica bootstrap ./bootstrap -COPY --chown=monica:monica config ./config -COPY --chown=monica:monica database ./database -COPY --chown=monica:monica public ./public -COPY --chown=monica:monica resources ./resources -COPY --chown=monica:monica routes ./routes - -RUN set -ex; \ - \ - mkdir -p bootstrap/cache; \ - mkdir -p storage; \ - chown -R monica:apache bootstrap/cache storage; \ - chmod -R g+w bootstrap/cache storage -COPY --chown=monica:monica .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 set -ex; \ - \ - 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 set -ex; \ - \ - composer global require hirak/prestissimo; \ - mkdir -p storage/framework/views; \ - composer install --no-interaction --no-suggest --no-progress --no-dev --ignore-platform-reqs; \ - composer global remove hirak/prestissimo; \ - \ - composer clear-cache; \ - rm -rf .composer - -USER root - -# Set crontab for schedules -RUN set -ex; \ - \ - cd /etc/periodic/hourly/; \ - { \ - echo '#!/bin/sh'; \ - echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/1 2> /proc/1/fd/2'; \ - } | tee monica; \ - chmod a+x monica - -# Cleanup -RUN set -ex; \ - \ - apk del .build-deps; \ - rm -rf /var/cache/apk/* - -COPY scripts/docker/entrypoint.sh \ - scripts/docker/cron.sh \ - scripts/docker/queue.sh \ - /usr/local/bin/ -ENTRYPOINT ["entrypoint.sh"] - -# Apache2 -RUN apk add apache2 php7-apache2 -COPY scripts/docker/apache2-foreground /usr/local/bin/ -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; \ - echo 'ServerName "monica"' > /etc/apache2/conf.d/hostname.conf - -EXPOSE 80 - -CMD ["apache2-foreground"] diff --git a/scripts/docker/fpm/Dockerfile b/scripts/docker/fpm/Dockerfile deleted file mode 100644 index 6355e796f..000000000 --- a/scripts/docker/fpm/Dockerfile +++ /dev/null @@ -1,177 +0,0 @@ -FROM alpine:latest - -# 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 set -ex; \ - \ - apk update; \ - apk upgrade; \ - apk add --virtual .build-deps \ - curl openssl bash \ - ; \ - apk add supervisor netcat-openbsd rsync \ - #- base - php7 php7-intl php7-openssl php7-ctype \ - php7-zip php7-zlib php7-opcache \ - php7-redis \ - #- Authentication Guards - php7-session php7-tokenizer \ - #- laravel/cashier sabre/vobject sabre/xml - php7-dom \ - #- intervention/image - php7-fileinfo \ - #- laravel/cashier - php7-gd \ - #- composer - php7-phar php7-json php7-iconv \ - #- laravel/framework sabre/vobject - php7-mbstring \ - #- league/flysystem-aws-s3-v3 - php7-simplexml \ - #- sabre/vobject sabre/xml - php7-xml php7-xmlreader php7-xmlwriter \ - #- mysql - php7-mysqli php7-pdo_mysql \ - #- pgsql - php7-pgsql php7-pdo_pgsql \ - #- vinkla/hashids - php7-bcmath \ - #- sentry/sentry - php7-curl \ - #- cbor-php (webauthn) - php7-gmp \ - #- web-token/jwt-signature-algorithm-eddsa - php7-sodium \ - #- bacon/bacon-qr-code - php7-imagick - -# Create a user to own all the code and assets and give them a working -# directory -RUN set -ex; \ - \ - mkdir -p /var/www/monica; \ - grep -q apache /etc/group || addgroup -S apache; \ - adduser -D monica apache -h /var/www/monica -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 --chown=monica:monica \ - readme.md \ - CONTRIBUTING.md \ - CHANGELOG.md \ - CONTRIBUTORS \ - LICENSE \ - artisan \ - composer.json \ - composer.lock \ - ./ -COPY --chown=monica:monica app ./app -COPY --chown=monica:monica bootstrap ./bootstrap -COPY --chown=monica:monica config ./config -COPY --chown=monica:monica database ./database -COPY --chown=monica:monica public ./public -COPY --chown=monica:monica resources ./resources -COPY --chown=monica:monica routes ./routes - -RUN set -ex; \ - \ - mkdir -p bootstrap/cache; \ - mkdir -p storage; \ - chown -R monica:apache bootstrap/cache storage; \ - chmod -R g+w bootstrap/cache storage -COPY --chown=monica:monica .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 - -# Composer installation -COPY scripts/docker/install-composer.sh /usr/local/sbin/ -RUN install-composer.sh - -# Install composer dependencies -USER monica -RUN set -ex; \ - \ - composer global require hirak/prestissimo; \ - mkdir -p storage/framework/views; \ - composer install --no-interaction --no-suggest --no-progress --no-dev --ignore-platform-reqs; \ - composer global remove hirak/prestissimo; \ - \ - composer clear-cache; \ - rm -rf .composer - -USER root - -# Set crontab for schedules -RUN set -ex; \ - \ - cd /etc/periodic/hourly/; \ - { \ - echo '#!/bin/sh'; \ - echo '/usr/bin/php /var/www/monica/artisan schedule:run -v > /proc/1/fd/2 2> /proc/1/fd/2'; \ - } | tee monica; \ - chmod a+x monica - -# Cleanup -RUN set -ex; \ - \ - apk del .build-deps; \ - rm -rf /var/cache/apk/* - -COPY scripts/docker/entrypoint.sh \ - scripts/docker/cron.sh \ - scripts/docker/queue.sh \ - /usr/local/bin/ -ENTRYPOINT ["entrypoint.sh"] - -# FPM -RUN apk add php7-fpm -RUN set -ex; \ - \ - cd /etc/php7/php-fpm.d; \ - { \ - echo '[global]'; \ - echo 'error_log = /proc/1/fd/2'; \ - echo; \ - echo '[www]'; \ - echo 'access.log = /proc/1/fd/2'; \ - echo 'catch_workers_output = yes'; \ - echo 'clear_env = no'; \ - } | tee docker.conf; \ - \ - { \ - echo '[global]'; \ - echo 'daemonize = no'; \ - echo; \ - echo '[www]'; \ - echo 'group = apache'; \ - echo 'listen = 9000'; \ - } | tee zz-docker.conf - -# Override stop signal to stop process gracefully -# https://github.com/php/php-src/blob/17baa87faddc2550def3ae7314236826bc1b1398/sapi/fpm/php-fpm.8.in#L163 -STOPSIGNAL SIGQUIT - -EXPOSE 9000 - -CMD ["php-fpm7"] diff --git a/scripts/docker/php-apache/Dockerfile b/scripts/docker/php-apache/Dockerfile deleted file mode 100644 index 3e56785d4..000000000 --- a/scripts/docker/php-apache/Dockerfile +++ /dev/null @@ -1,186 +0,0 @@ -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 set -ex; \ - \ - 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 supervisor rsync \ - ; \ - mkdir /var/log/supervisord /var/run/supervisord; \ - rm -rf /var/lib/apt/lists/* - -# Install common extensions -RUN set -ex; \ - \ - apt-get update; \ - apt-get -y autoremove; \ - apt-get -y --no-install-recommends install \ - libicu-dev \ - zlib1g-dev \ - libzip-dev \ - libpng-dev \ - libxml2-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libgmp-dev \ - libsodium-dev \ - libmagickwand-dev \ - ; \ - 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 \ - sodium \ - mbstring \ - opcache \ - ; \ - \ - printf "\n" | pecl install imagick ; \ - docker-php-ext-enable imagick ; \ - \ - apt-get -y remove \ - icu-devtools \ - libicu-dev \ - zlib1g-dev \ - libzip-dev \ - libpng-dev \ - libxml2-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libgmp-dev \ - libsodium-dev \ - libmagickwand-dev \ - ; \ - apt-get -y clean; \ - rm -rf /var/lib/apt/lists/* - -# Create a user to own all the code and assets and give them a working -# directory -RUN set -ex; \ - \ - 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 --chown=monica:www-data \ - readme.md \ - CONTRIBUTING.md \ - CHANGELOG.md \ - CONTRIBUTORS \ - LICENSE \ - artisan \ - composer.json \ - composer.lock \ - ./ -COPY --chown=monica:www-data app ./app -COPY --chown=monica:www-data bootstrap ./bootstrap -COPY --chown=monica:www-data config ./config -COPY --chown=monica:www-data database ./database -COPY --chown=monica:www-data public ./public -COPY --chown=monica:www-data resources ./resources -COPY --chown=monica:www-data routes ./routes - -RUN set -ex; \ - \ - mkdir -p bootstrap/cache; \ - mkdir -p storage; \ - chown -R monica:www-data bootstrap/cache storage; \ - chmod -R g+w bootstrap/cache storage -COPY --chown=monica:www-data .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 set -ex; \ - \ - 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 set -ex; \ - \ - composer global require hirak/prestissimo; \ - mkdir -p storage/framework/views; \ - composer install --no-interaction --no-suggest --no-progress --no-dev --ignore-platform-reqs; \ - composer global remove hirak/prestissimo; \ - \ - composer clear-cache; \ - rm -rf .composer - -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 > /proc/1/fd/1 2> /proc/1/fd/2'; \ - } | tee monica; \ - chmod a+x monica - -COPY scripts/docker/entrypoint.sh \ - scripts/docker/php-apache/cron.sh \ - scripts/docker/queue.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 set -ex; \ - \ - echo 'ServerName "monica"' > /etc/apache2/conf-available/hostname.conf; \ - a2enconf hostname; \ - a2enmod rewrite cache headers - -EXPOSE 80 - -CMD ["apache2-foreground"] diff --git a/scripts/docker/php-apache/cron.sh b/scripts/docker/php-apache/cron.sh deleted file mode 100644 index da6dca84c..000000000 --- a/scripts/docker/php-apache/cron.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -eu - -/usr/sbin/cron -f -L 0