Skip to content

Automate your workflow

Use docker image

The CLI is available in a docker image with PHP 8.2 and composer pre-installed on Docker hub. You can use latest tag or specify the version.

Example of CI/CD with gitlab

Example of .gitlab-ci.yml file to put in your git project :

stages:
  - 📦️ build
  - 🚀 publish

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  GIT_SUBMODULE_FORCE_HTTPS: "true"
  PLUGIN_SLUG: dummy
  WPC_CLI_VERSION: 1.0.17
  WPC_API_KEY: 00000000-0000-0000-0000-000000000000

⛏️ generate zip:
  stage: 📦️ build
  image: wpcontent/wpc-cli:${WPC_CLI_VERSION}
  script:
    - composer install --no-dev --optimize-autoloader
    - wpc plugin:build --slug=${PLUGIN_SLUG} --output-dir=./ .
  artifacts:
    paths:
      - ./${PLUGIN_SLUG}.zip

🗂️ push to registry:
  stage: 🚀 publish
  image: wpcontent/wpc-cli:${WPC_CLI_VERSION}
  script:
    - wpc plugin:push -m "${CI_COMMIT_MESSAGE}" ./${PLUGIN_SLUG}.zip
  when: manual

workflow:
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

Use CLI in your Dockerfile

You can grab the latest version by copying from the official repository :

FROM php:8.3-alpine

COPY --from=wpcontent/wpc-cli:latest /usr/local/bin/wpc /usr/local/bin/wpc

# Run any command :
# RUN wpc plugin:build

Original Dockerfile

If you want to create your own image, you can find original Dockerfile below.

FROM php:8.2-alpine AS build
LABEL Maintainer="Happy Monkey <support@mkey.fr>"

# Prepare system
RUN apk update && apk add --no-cache \
    gettext \
    git \
    zip \
    libzip-dev \
    curl \
    sudo \
    unzip \
    icu-dev \
    bzip2-dev \
    libpng-dev \
    libjpeg-turbo-dev \
    freetype-dev \
    postgresql-dev \
    g++ \
    make \
    autoconf

# Install PHP extensions
RUN docker-php-ext-install \
    pdo_mysql \
    pdo_pgsql \
    bcmath \
    bz2 \
    gd \
    intl \
    zip

# Clean up
RUN rm -rf /var/cache/apk/*

# Install PHP modules
RUN docker-php-ext-configure gd --with-freetype=/usr --with-jpeg=/usr && \
    docker-php-ext-install \
     bz2 \
     zip \
     gd \
     intl \
     bcmath \
     opcache \
     calendar \
     pdo_mysql \
     mysqli \
     pdo_pgsql \
     pgsql

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Add main command
COPY ./wpc.phar /usr/local/bin/wpc
RUN chmod +x /usr/local/bin/wpc

WORKDIR /app