Compare commits
14 Commits
0b36204061
...
master
Author | SHA1 | Date |
---|---|---|
3wc | 868f85fb2a | |
3wc | 04397f138f | |
3wc | d317705c94 | |
3wc | e5974bed00 | |
3wc | 878eb2f81f | |
3wc | 2a43f7feea | |
3wc | 083791aaa5 | |
Mayel | d8580b4962 | |
Mayel | e0eff8c3fa | |
Mayel | 1500ca7324 | |
Mayel | b1375c5cc3 | |
Mayel | 2e7a8c66f1 | |
Mayel | 32d2f3f04f | |
Mayel | 21ab89946a |
20
.drone.yml
20
.drone.yml
|
@ -3,10 +3,12 @@ kind: pipeline
|
|||
name: deploy to swarm-test.autonomic.zone
|
||||
steps:
|
||||
- name: deployment
|
||||
image: decentral1se/stack-ssh-deploy:latest
|
||||
image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest
|
||||
settings:
|
||||
host: swarm-test.autonomic.zone
|
||||
stack: custom-php
|
||||
networks:
|
||||
- proxy
|
||||
generate_secrets: true
|
||||
purge: true
|
||||
deploy_key:
|
||||
|
@ -24,11 +26,17 @@ trigger:
|
|||
- master
|
||||
---
|
||||
kind: pipeline
|
||||
name: recipe release
|
||||
name: generate recipe catalogue
|
||||
steps:
|
||||
- name: release a new version
|
||||
image: thecoopcloud/drone-abra:latest
|
||||
image: plugins/downstream
|
||||
settings:
|
||||
command: recipe wordpress release
|
||||
deploy_key:
|
||||
from_secret: abra_bot_deploy_key
|
||||
server: https://build.coopcloud.tech
|
||||
token:
|
||||
from_secret: drone_abra-bot_token
|
||||
fork: true
|
||||
repositories:
|
||||
- coop-cloud/auto-recipes-catalogue-json
|
||||
|
||||
trigger:
|
||||
event: tag
|
||||
|
|
11
.env.sample
11
.env.sample
|
@ -5,9 +5,16 @@ DOMAIN=example.com
|
|||
#EXTRA_DOMAINS=', `www.example.com`'
|
||||
LETS_ENCRYPT_ENV=production
|
||||
|
||||
## Extensions you do NOT need, out of this list of installed extensions: https://github.com/adhocore/docker-phpfpm#php80
|
||||
#PHP_EXTENSIONS_TO_DISABLE="calendar"
|
||||
ROOT_PATH=/var/www/html
|
||||
PHP_VERSION=7.4
|
||||
# environment (needed for PHP frameworks like laravel/symphony)
|
||||
APP_ENV=prod
|
||||
|
||||
## Extra extensions you need (run `abra app YOURAPPDOMAIN run app "php -m"` to see active extensions)
|
||||
PHP_EXTENSIONS="pdo_mysql"
|
||||
|
||||
# Optional database
|
||||
#COMPOSE_FILE="compose.yml:compose.mariadb.yml"
|
||||
SECRET_DB_ROOT_PASSWORD_VERSION=v1
|
||||
SECRET_DB_PASSWORD_VERSION=v1
|
||||
|
||||
|
|
48
README.md
48
README.md
|
@ -1,18 +1,17 @@
|
|||
# custom-php
|
||||
|
||||
|
||||
Coöp Cloud + [PHP](https://php.org) + MariaDB + Nginx = 🥳
|
||||
Coöp Cloud + [PHP](https://php.org) + MariaDB (optional) + Nginx = 🥳
|
||||
|
||||
<!-- metadata -->
|
||||
|
||||
- **Category**: Apps
|
||||
- **Status**: ❶💚
|
||||
- **Image**: [`php`](https://hub.docker.com/_/php), ❶💚, upstream
|
||||
- **Healthcheck**: Yes
|
||||
- **Backups**: Yes
|
||||
- **Email**: ❶💚
|
||||
- **Tests**: ❷💛
|
||||
- **SSO**: No
|
||||
* **Category**: Development
|
||||
* **Status**: 3, stable
|
||||
* **Image**: [`php`](https://hub.docker.com/_/php), 4, upstream
|
||||
* **Healthcheck**: Yes
|
||||
* **Backups**: Yes
|
||||
* **Email**: 3
|
||||
* **Tests**: 2
|
||||
* **SSO**: No
|
||||
|
||||
<!-- endmetadata -->
|
||||
|
||||
|
@ -22,28 +21,43 @@ Coöp Cloud + [PHP](https://php.org) + MariaDB + Nginx = 🥳
|
|||
2. Deploy [`coop-cloud/traefik`][cc-traefik]
|
||||
3. `abra app new custom-php --secrets` (optionally with `--pass` if you'd like
|
||||
to save secrets in `pass`)
|
||||
4. `abra app YOURAPPDOMAIN config` - be sure to change `$DOMAIN` to something that resolves to
|
||||
4. `abra app config YOURAPPDOMAIN`
|
||||
- be sure to change `$DOMAIN` to something that resolves to
|
||||
your Docker swarm box
|
||||
5. `abra app YOURAPPDOMAIN deploy`
|
||||
6. Copy your site files using something like: `abra app YOURAPPDOMAIN cp index.html app:/var/www/html/` or if you want to copy an entire directory: `tar cf - ./mysite | abra app YOURAPPDOMAIN cp - app:/var/www/html/`
|
||||
- if you need to enable the optional database, uncomment `COMPOSE_FILE="compose.yml:compose.mariadb.yml"` in which case configure your site to load the DB credentials from env:
|
||||
- `getenv('DB_NAME');`
|
||||
- `getenv('DB_HOST');`
|
||||
- `getenv('DB_USER');`
|
||||
- `@file_get_contents(getenv('DB_PASSWORD_FILE'));`
|
||||
5. Deploy with `abra app deploy YOURAPPDOMAIN`
|
||||
6. Copy your site files using something like: `abra app cp YOURAPPDOMAIN index.html app:/var/www/html/` or if you want to copy an entire directory: `tar -cf - -C my_site/path/here . | abra app YOURAPPDOMAIN cp - app:/var/www/html/`
|
||||
6. Use [restore functionality](https://docs.coopcloud.tech/backup-restore/) to import a SQL file into the db
|
||||
6. Open the configured domain in your browser to check all is good
|
||||
|
||||
|
||||
## Extra
|
||||
|
||||
Indicate extensions you need in the `PHP_EXTENSIONS` env var. The entrypoint script will install them on startup.
|
||||
|
||||
You can see what PHP extensions compiled into the image by checking the output of `abra app run YOURAPPDOMAIN app "php -m"`
|
||||
|
||||
You can see the PHP config and environment by checking the output of `abra app run YOURAPPDOMAIN app "php -i"`
|
||||
|
||||
|
||||
## Email
|
||||
|
||||
There is a local or remote SMTP relay configuration available.
|
||||
|
||||
- **local**: `COMPOSE_FILE=compose.yml:compose.mailrelay.yml`
|
||||
- **remote**: `COMPOSE_FILE=compose.yml:compose.mailrelay.yml:compose.smtp.yml`
|
||||
* **local**: `COMPOSE_FILE=compose.yml:compose.mailrelay.yml`
|
||||
* **remote**: `COMPOSE_FILE=compose.yml:compose.mailrelay.yml:compose.smtp.yml`
|
||||
|
||||
Below are the instructions for the local relay.
|
||||
|
||||
1. Deploy [`postfix-relay`][cc-postfix-relay]
|
||||
2. `abra app YOURAPPDOMAIN config`, and uncomment the email lines; change
|
||||
2. `abra app config YOURAPPDOMAIN`, and uncomment the email lines; change
|
||||
`MAIL_FROM` to make sure the domain is the same as `postfix-relay`'s
|
||||
`$DOMAIN` or in its `$EXTRA_SENDER_DOMAINS`
|
||||
3. `abra app YOURAPPDOMAIN deploy`
|
||||
3. `abra app deploy YOURAPPDOMAIN`
|
||||
|
||||
[abra]: https://git.autonomic.zone/autonomic-cooperative/abra
|
||||
[cc-traefik]: https://git.autonomic.zone/coop-cloud/traefik
|
||||
|
|
7
abra.sh
7
abra.sh
|
@ -1,6 +1,7 @@
|
|||
export NGINX_DEFAULT_CONF_VERSION=v6
|
||||
export PHP_UPLOADS_CONF_VERSION=v3
|
||||
export ENTRYPOINT_CONF_VERSION=v2
|
||||
# export PHP_VERSION=7.4
|
||||
export NGINX_DEFAULT_CONF_VERSION=v7
|
||||
export PHP_UPLOADS_CONF_VERSION=v4
|
||||
export ENTRYPOINT_CONF_VERSION=v1
|
||||
export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1
|
||||
export MSMTP_CONF_VERSION=v3
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
- DB_HOST=${STACK_NAME}_db
|
||||
# - DB_HOST=db
|
||||
- DB_USER=site
|
||||
- DB_PASSWORD_FILE=/run/secrets/db_password
|
||||
- DB_NAME=site
|
||||
secrets:
|
||||
- db_password
|
||||
depends_on:
|
||||
- db
|
||||
db:
|
||||
image: "mariadb:10.6"
|
||||
volumes:
|
||||
- "mariadb:/var/lib/mysql"
|
||||
networks:
|
||||
- backend
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
|
||||
- MYSQL_DATABASE=site
|
||||
- MYSQL_USER=site
|
||||
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
|
||||
secrets:
|
||||
- db_password
|
||||
- db_root_password
|
||||
deploy:
|
||||
labels: ['coop-cloud.${STACK_NAME}.db.version=10.6-718cb856']
|
||||
volumes:
|
||||
mariadb:
|
||||
secrets:
|
||||
db_root_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_root_password_${SECRET_DB_ROOT_PASSWORD_VERSION}
|
||||
db_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
|
60
compose.yml
60
compose.yml
|
@ -1,38 +1,31 @@
|
|||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
image: php:8.0-fpm-alpine3.13
|
||||
image: php:${PHP_VERSION}-fpm-alpine3.13
|
||||
volumes:
|
||||
- "site_content:/var/www/html/"
|
||||
networks:
|
||||
- internal
|
||||
- backend
|
||||
- proxy
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_USER=site
|
||||
- DB_PASSWORD_FILE=/run/secrets/db_password
|
||||
- DB_NAME=site
|
||||
- PHP_EXTENSIONS_TO_DISABLE
|
||||
secrets:
|
||||
- db_password
|
||||
- PHP_EXTENSIONS
|
||||
- APP_ENV
|
||||
configs:
|
||||
- source: php_uploads_conf
|
||||
target: /usr/local/etc/php/conf.d/uploads.ini
|
||||
# - source: entrypoint_conf
|
||||
# target: /docker-entrypoint.sh
|
||||
# mode: 0555
|
||||
# entrypoint: /docker-entrypoint.sh
|
||||
depends_on:
|
||||
- db
|
||||
- source: entrypoint_conf
|
||||
target: /docker-entrypoint.sh
|
||||
mode: 0555
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
deploy:
|
||||
update_config:
|
||||
failure_action: rollback
|
||||
order: start-first
|
||||
labels:
|
||||
- coop-cloud.${STACK_NAME}.app.version=8.0-92fac7ac
|
||||
- coop-cloud.${STACK_NAME}.app.version=${PHP_VERSION}-92fac7ac
|
||||
frontend:
|
||||
image: nginx:1.19.2
|
||||
image: nginx:1.20-alpine
|
||||
networks:
|
||||
- internal
|
||||
- proxy
|
||||
depends_on:
|
||||
- app
|
||||
|
@ -49,7 +42,7 @@ services:
|
|||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
|
||||
- coop-cloud.${STACK_NAME}.frontend.version=1.19.2-c628b67d
|
||||
- coop-cloud.${STACK_NAME}.frontend.version=1.20-c628b67d
|
||||
volumes:
|
||||
- site_content:/var/www/html/
|
||||
configs:
|
||||
|
@ -57,43 +50,20 @@ services:
|
|||
target: /etc/nginx/conf.d/default.conf
|
||||
environment:
|
||||
- STACK_NAME
|
||||
- ROOT_PATH
|
||||
# healthcheck:
|
||||
# test: ["CMD", "curl", "-f", "http://localhost"]
|
||||
# interval: 30s
|
||||
# timeout: 10s
|
||||
# retries: 10
|
||||
# start_period: 1m
|
||||
db:
|
||||
image: "mariadb:10.6"
|
||||
volumes:
|
||||
- "mariadb:/var/lib/mysql"
|
||||
networks:
|
||||
- internal
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
|
||||
- MYSQL_DATABASE=site
|
||||
- MYSQL_USER=site
|
||||
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
|
||||
secrets:
|
||||
- db_password
|
||||
- db_root_password
|
||||
deploy:
|
||||
labels: ['coop-cloud.${STACK_NAME}.db.version=10.6-718cb856']
|
||||
networks:
|
||||
internal:
|
||||
internal: true
|
||||
backend:
|
||||
# internal: true
|
||||
proxy:
|
||||
external: true
|
||||
volumes:
|
||||
mariadb:
|
||||
site_content:
|
||||
secrets:
|
||||
db_root_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_root_password_${SECRET_DB_ROOT_PASSWORD_VERSION}
|
||||
db_password:
|
||||
external: true
|
||||
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
|
||||
configs:
|
||||
entrypoint_conf:
|
||||
name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
{{ if (env "PHP_EXTENSIONS") }}
|
||||
echo Installing PHP extensions: {{ env "PHP_EXTENSIONS" }}
|
||||
docker-php-ext-install {{ env "PHP_EXTENSIONS" }}
|
||||
{{ end }}
|
||||
|
||||
if [ -n "$@" ]; then
|
||||
"$@"
|
||||
fi
|
||||
exec "$@"
|
||||
|
||||
php-fpm
|
|
@ -4,7 +4,7 @@ server {
|
|||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
root /var/www/html;
|
||||
root {{ env "ROOT_PATH" }};
|
||||
|
||||
#charset koi8-r;
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
file_uploads = On
|
||||
upload_max_filesize = 256M
|
||||
post_max_size = 256M
|
||||
log_errors = On
|
||||
error_log = /dev/stderr
|
Loading…
Reference in New Issue