Implement proper Cloudron structure with supervisor
This commit is contained in:
21
Dockerfile
21
Dockerfile
@ -1,27 +1,22 @@
|
||||
FROM pentacent/keila:0.14
|
||||
FROM cloudron/base:4.2.0
|
||||
|
||||
# Install Cloudron requirements
|
||||
USER root
|
||||
RUN addgroup --gid 1000 cloudron && adduser --disabled-password --gecos "" --uid 1000 --gid 1000 cloudron
|
||||
|
||||
# Install additional packages
|
||||
# Install runtime dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
nginx \
|
||||
postgresql-client \
|
||||
sudo \
|
||||
supervisor \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Setup directories
|
||||
RUN mkdir -p /app/code /app/data /tmp/nginx \
|
||||
&& chown -R cloudron:cloudron /app/code /app/data
|
||||
# Copy Keila from official image
|
||||
COPY --from=pentacent/keila:0.14 /opt/app /app/pkg
|
||||
|
||||
# Copy configuration files
|
||||
COPY start.sh /app/code/start.sh
|
||||
COPY supervisor/ /etc/supervisor/conf.d/
|
||||
COPY nginx.conf /etc/nginx/sites-available/default
|
||||
COPY nginx_main.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Set permissions
|
||||
RUN chmod +x /app/code/start.sh
|
||||
RUN chmod +x /app/code/start.sh && \
|
||||
chown -R cloudron:cloudron /app/code /app/pkg
|
||||
|
||||
WORKDIR /app/code
|
||||
|
||||
|
@ -6,11 +6,6 @@ server {
|
||||
root /tmp;
|
||||
|
||||
client_max_body_size 100m;
|
||||
client_body_temp_path /tmp/nginx/body;
|
||||
fastcgi_temp_path /tmp/nginx/fastcgi;
|
||||
proxy_temp_path /tmp/nginx/proxy;
|
||||
scgi_temp_path /tmp/nginx/scgi;
|
||||
uwsgi_temp_path /tmp/nginx/uwsgi;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
|
@ -1,29 +0,0 @@
|
||||
user cloudron;
|
||||
worker_processes auto;
|
||||
pid /tmp/nginx.pid;
|
||||
error_log /dev/stderr;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
access_log /dev/stdout;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
|
||||
client_body_temp_path /tmp/nginx/body;
|
||||
fastcgi_temp_path /tmp/nginx/fastcgi;
|
||||
proxy_temp_path /tmp/nginx/proxy;
|
||||
scgi_temp_path /tmp/nginx/scgi;
|
||||
uwsgi_temp_path /tmp/nginx/uwsgi;
|
||||
|
||||
include /etc/nginx/sites-available/default;
|
||||
}
|
26
start.sh
26
start.sh
@ -3,10 +3,10 @@ set -eu
|
||||
|
||||
echo "Starting Keila on Cloudron"
|
||||
|
||||
# Copy Keila release to /app/data on first run
|
||||
# Initialize Keila data directory by copying from /app/pkg
|
||||
if [[ ! -d "/app/data/keila" ]]; then
|
||||
echo "==> Initializing Keila installation"
|
||||
cp -r /opt/app /app/data/keila
|
||||
cp -r /app/pkg /app/data/keila
|
||||
chown -R cloudron:cloudron /app/data/keila
|
||||
fi
|
||||
|
||||
@ -17,13 +17,12 @@ if [[ ! -f "/app/data/secret_key_base" ]]; then
|
||||
chown cloudron:cloudron /app/data/secret_key_base
|
||||
fi
|
||||
|
||||
# Set environment variables
|
||||
# Set environment variables for supervisor
|
||||
export SECRET_KEY_BASE=$(cat /app/data/secret_key_base)
|
||||
export DB_URL="${CLOUDRON_POSTGRESQL_URL}"
|
||||
export URL_HOST="${CLOUDRON_APP_DOMAIN}"
|
||||
export URL_SCHEMA="https"
|
||||
export URL_PORT="443"
|
||||
export PORT="4000"
|
||||
|
||||
# Configure SMTP
|
||||
export MAILER_SMTP_HOST="${CLOUDRON_MAIL_SMTP_SERVER}"
|
||||
@ -37,10 +36,8 @@ export USER_CONTENT_DIR="/app/data/uploads"
|
||||
mkdir -p /app/data/uploads
|
||||
chown cloudron:cloudron /app/data/uploads
|
||||
|
||||
# Disable registration for security (admin can create users)
|
||||
# Disable registration for security
|
||||
export DISABLE_REGISTRATION="true"
|
||||
|
||||
# Set database pool size
|
||||
export DATABASE_POOL_SIZE="10"
|
||||
|
||||
# Create root user credentials file if not exists
|
||||
@ -55,19 +52,8 @@ if [[ ! -f "/app/data/root_credentials" ]]; then
|
||||
chmod 600 /app/data/root_credentials
|
||||
fi
|
||||
|
||||
echo "==> Creating nginx temp directories"
|
||||
mkdir -p /tmp/nginx/body /tmp/nginx/fastcgi /tmp/nginx/proxy /tmp/nginx/scgi /tmp/nginx/uwsgi
|
||||
|
||||
echo "==> Starting nginx"
|
||||
nginx -t
|
||||
nginx
|
||||
|
||||
echo "==> Running database migrations"
|
||||
cd /app/data/keila
|
||||
sudo -u cloudron -E /app/data/keila/bin/keila eval "Keila.Release.migrate()"
|
||||
|
||||
echo "==> Starting Keila application"
|
||||
cd /app/data/keila
|
||||
# Change the internal port since nginx listens on 4000
|
||||
export PORT="4001"
|
||||
exec sudo -u cloudron -E /app/data/keila/bin/keila start
|
||||
echo "==> Starting supervisor"
|
||||
exec /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon
|
10
supervisor/keila.conf
Normal file
10
supervisor/keila.conf
Normal file
@ -0,0 +1,10 @@
|
||||
[program:keila]
|
||||
command=/app/data/keila/bin/keila start
|
||||
directory=/app/data
|
||||
user=cloudron
|
||||
autorestart=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PORT=4001,SECRET_KEY_BASE=%(ENV_SECRET_KEY_BASE)s,DB_URL=%(ENV_DB_URL)s,URL_HOST=%(ENV_URL_HOST)s,URL_SCHEMA=%(ENV_URL_SCHEMA)s,URL_PORT=%(ENV_URL_PORT)s,MAILER_SMTP_HOST=%(ENV_MAILER_SMTP_HOST)s,MAILER_SMTP_PORT=%(ENV_MAILER_SMTP_PORT)s,MAILER_SMTP_USERNAME=%(ENV_MAILER_SMTP_USERNAME)s,MAILER_SMTP_PASSWORD=%(ENV_MAILER_SMTP_PASSWORD)s,MAILER_SMTP_FROM_EMAIL=%(ENV_MAILER_SMTP_FROM_EMAIL)s,USER_CONTENT_DIR=%(ENV_USER_CONTENT_DIR)s,DISABLE_REGISTRATION=%(ENV_DISABLE_REGISTRATION)s,DATABASE_POOL_SIZE=%(ENV_DATABASE_POOL_SIZE)s
|
8
supervisor/nginx.conf
Normal file
8
supervisor/nginx.conf
Normal file
@ -0,0 +1,8 @@
|
||||
[program:nginx]
|
||||
command=nginx -g "daemon off;"
|
||||
autorestart=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
user=root
|
Reference in New Issue
Block a user