add: improved workflow for caprover
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
name: Deploy to CapRover
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Pack it up
|
||||
run: |
|
||||
tar -cvf deploy.tar \
|
||||
captain-definition \
|
||||
composer.json \
|
||||
composer.lock \
|
||||
app/ \
|
||||
docker/wordpress/Dockerfile \
|
||||
docker/wordpress/scripts/
|
||||
|
||||
- name: Deploy to CapRover
|
||||
uses: caprover/deploy-from-github@v1.0.1
|
||||
with:
|
||||
server: ${{ vars.CAPROVER_SERVER }}
|
||||
app: ${{ vars.APP_NAME }}
|
||||
token: ${{ secrets.CAPROVER_APP_TOKEN }}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"schemaVersion": 2,
|
||||
"dockerfilePath": "docker/wordpress/Dockerfile"
|
||||
}
|
||||
+2
-1
@@ -26,7 +26,8 @@ services:
|
||||
container_name: app
|
||||
image: hackeamos/wp
|
||||
build:
|
||||
context: './docker/wordpress'
|
||||
context: .
|
||||
dockerfile: ./docker/wordpress/Dockerfile
|
||||
volumes:
|
||||
- webroot:/var/www/html
|
||||
- ./app/themes:/var/www/html/wp-content/themes
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
ARG WP_VERSION=6
|
||||
ARG PHP_VERSION=8.3
|
||||
|
||||
# set wordpress and PHP versions
|
||||
FROM wordpress:${WP_VERSION}-php${PHP_VERSION}-fpm-alpine
|
||||
|
||||
# clean core from default themes and plugins
|
||||
RUN rm -rf /usr/src/wordpress/wp-content/themes/* && rm -rf /usr/src/wordpress/wp-content/plugins/*
|
||||
COPY app/* /usr/src/wordpress
|
||||
|
||||
# install system dependencies
|
||||
RUN apk add --no-cache msmtp mysql-client;
|
||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||
chmod +x wp-cli.phar && \
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
# install composer dependencies
|
||||
COPY composer.json composer.lock ./
|
||||
RUN --mount=type=secret,id=GITEA_TOKEN \
|
||||
export TOKEN=$(cat /run/secrets/GITEA_TOKEN) && \
|
||||
composer config --global auth.http-basic.seu-gitea.com token $TOKEN && \
|
||||
composer install --no-dev --optimize-autoloader
|
||||
|
||||
# modify docker entrypoint for running any .sh scripts found under /usr/local/bin/docker-entrypoint.d
|
||||
# scripts will run as www-data if endedd with .unpriv.sh or as root elsewhere
|
||||
RUN cp -avf /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.original && \
|
||||
sed -i '/^[[:space:]]*exec "$@"[[:space:]]*/d' /usr/local/bin/docker-entrypoint.sh && \
|
||||
cat << EOF >> /usr/local/bin/docker-entrypoint.sh
|
||||
@@ -20,11 +40,6 @@ fi
|
||||
|
||||
exec "\$@";
|
||||
EOF
|
||||
COPY docker/wordpress/scripts/docker-entrypoint.d/* /docker-entrypoint.d/
|
||||
|
||||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||
chmod +x wp-cli.phar && \
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
# Copy sub scripts and allows execution
|
||||
COPY ./scripts/docker-entrypoint.d/* /docker-entrypoint.d/
|
||||
RUN chmod +x /docker-entrypoint.d/*.sh
|
||||
@@ -1,8 +1,4 @@
|
||||
# Instals msmtp if a SMTP_HOST var was configured
|
||||
if test -n "${SMTP_HOST}"; then
|
||||
|
||||
apk add --no-cache msmtp;
|
||||
|
||||
if test -z "${SMTP_PORT:-}"; then
|
||||
if test "${SMTP_TLS:-on}" = "off"; then
|
||||
SMTP_PORT=25;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
set -e
|
||||
|
||||
REQUIRED_VARS="WORDPRESS_SITEURL WORDPRESS_BLOGNAME WORDPRESS_ADMIN_USER WORDPRESS_ADMIN_EMAIL";
|
||||
DEFAULT_THEME="twentytwentyfive"
|
||||
|
||||
|
||||
for varname in ${REQUIRED_VARS}; do
|
||||
value="$(export -p | grep $varname | cut -d '=' -f 2 | xargs)"
|
||||
@@ -12,7 +10,7 @@ for varname in ${REQUIRED_VARS}; do
|
||||
fi
|
||||
done;
|
||||
|
||||
pwd
|
||||
GET_LOCK=$(wp db query "SELECT GET_LOCK('wp_install_lock', 10);" --silent --skip-column-names)
|
||||
|
||||
if which wp && ! wp core is-installed; then
|
||||
echo "Installing WordPress via WP-CLI..."
|
||||
@@ -25,5 +23,5 @@ if which wp && ! wp core is-installed; then
|
||||
fi
|
||||
|
||||
if test "$(wp theme list --format=count)" = "0"; then
|
||||
wp theme install twentytwentyfive --force --activate;
|
||||
wp theme install ${WORDPRESS_DEFAULT_THEME:-twentytwentysix} --force --activate;
|
||||
fi
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "=== RUNTIME SETUP (start) ==="
|
||||
|
||||
if [ -n "${SMTP_HOST}" ]; then
|
||||
echo "Configurando msmtp para ${SMTP_HOST}..."
|
||||
cat > /etc/msmtprc <<EOF
|
||||
defaults
|
||||
auth ${SMTP_AUTH:-on}
|
||||
tls ${SMTP_TLS:-on}
|
||||
syslog on
|
||||
|
||||
account default
|
||||
host ${SMTP_HOST}
|
||||
port ${SMTP_PORT:-587}
|
||||
from ${SMTP_FROM:-${WORDPRESS_ADMIN_EMAIL}}
|
||||
user ${SMTP_USER}
|
||||
password ${SMTP_PASSWORD}
|
||||
EOF
|
||||
chmod 600 /etc/msmtprc
|
||||
|
||||
# Aponta o PHP para o msmtp
|
||||
printf 'sendmail_path = "/usr/bin/msmtp -t"\nmail.add_x_header = On' > /usr/local/etc/php/conf.d/99-mail.ini
|
||||
else
|
||||
echo "Nenhum SMTP_HOST detectado. Usando solução padrão do PHP."
|
||||
rm -f /usr/local/etc/php/conf.d/99-mail.ini
|
||||
fi
|
||||
|
||||
echo "=== RUNTIME SETUP (end) ==="
|
||||
|
||||
# O "pulo do gato": executa o entrypoint original da imagem do WordPress
|
||||
# passando todos os argumentos (geralmente 'php-fpm')
|
||||
exec docker-entrypoint.sh "$@"
|
||||
Reference in New Issue
Block a user