Skip to content

Deploying a WooCommerce App

Introduction

WooCommerce brings full-featured e-commerce to WordPress. This guide shows how to containerize WooCommerce with a Dockerfile, connect it to MySQL, persist uploads and themes, and deploy it to Klutch.sh over HTTP.

Prerequisites

  • GitHub repository containing your Dockerfile.
  • MySQL database (managed or deployed separately).
  • Klutch.sh project ready in klutch.sh/app.

Project structure

.
└── Dockerfile

Sample Dockerfile

FROM wordpress:6.5-php8.2-apache
# Default WordPress/WooCommerce port
ENV APACHE_PORT=80
EXPOSE 80

Required environment variables

  • WORDPRESS_DB_HOST – MySQL host and port (e.g., db:3306 or managed host)
  • WORDPRESS_DB_USER
  • WORDPRESS_DB_PASSWORD
  • WORDPRESS_DB_NAME
  • APACHE_PORT=80

Optional environment variables

  • WORDPRESS_TABLE_PREFIX=wp_
  • WORDPRESS_DEBUG=false
  • WP_MEMORY_LIMIT=256M

Persistence

Persist plugins, themes, and uploads:

  • Mount path: /var/www/html/wp-content
  • Size: based on expected media and plugin assets

Networking

  • Protocol: HTTP
  • Internal port: 80
  • Users reach https://example-app.klutch.sh while Klutch.sh routes to port 80 inside the container.
Terminal window
curl -I http://localhost

Deployment on Klutch.sh

  1. Push your Dockerfile to GitHub.
  2. In klutch.sh/app, create a new app and select GitHub as the source.
  3. Klutch.sh automatically detects the Dockerfile in the repository root.
  4. Select HTTP traffic and set the internal port to 80.
  5. Add environment variables for WORDPRESS_DB_HOST, WORDPRESS_DB_USER, WORDPRESS_DB_PASSWORD, and WORDPRESS_DB_NAME. Mark secrets as sensitive.
  6. Attach a persistent volume at /var/www/html/wp-content sized for uploads, plugins, and themes.
  7. Deploy. Finish the WordPress setup wizard, install WooCommerce, and run its onboarding.

Verification

  • UI: open https://example-app.klutch.sh and confirm the WordPress home page loads.

  • Quick check:

    Terminal window
    curl -I https://example-app.klutch.sh

Next steps

  • Configure HTTPS at the edge and set your site URL inside WordPress.
  • Set up backups for MySQL and the /var/www/html/wp-content volume.
  • Add caching/CDN and security plugins as needed for production traffic.