A builder image for Bitbucket Pipelines to be used with php projects tailored to WordPress.
1.0K
This builder image is a basic image which we can internally use to build our projects through Bitbucket Pipelines.
Please read the changelog and check if upgrading is possible.
pnd build:security-updates <path-to-wordpress> to run this command i.e. pnd build:security-updates public/wordpressPlease read the changelog and check if upgrading is possible.
Added support for PHP 8.3
Added support for multiple PHP versions using pnd build:switch-php [7.4|8.0|8.1|8.2|8.3]
Downgraded requirements for pnd application so it works on all php-versions from 7.4 until 8.3
Updated default state to build in PHP 8.3 (was 8.1)
Updated default node version from 18.15.0 to 20.14.0 (current LTS version)
Added new templates:
Add salts.php generator/ symlinker
Added option to add custom destination build dir (which defaults to ~/builds if not set)
Note: all templates have been updated to accomodate this different build folder as well
This release contains some possible breaking changes. Please read the changelog and check if upgrading is possible.
pnd build:switch-php [8.2|8.3|8.4]pnd nvm:install and pnd nvm:use)This version is deprecated. Do not use for new projects.
The image is based on Ubuntu, and contains:
Too drasticly reduce the size of the builder image (and to speed up the building process on an up-to-date NPM version) all older versions of NPM are excluded by default. Use the following command to install another version during run-time:
nvm install 18.4.0
The image contains a php-written command line application which can help you with deploying your application and simplifies the deployment yaml scripts. See below for more information on the commands that are written explicitely for Proud Nerds Deployments
A simple command that uses the pnd workflow to execute shell scripts on the build server. It takes care of setting the +x addition on the script file.
This sets the php executable to the given version because some projects require a different PHP version during the build phase. Default PHP version is 8.3, possible values:
pnd build:switch-php 8.4
This script is run on the build server. To run a script on the destination server see the documentation for the pnd ssh:script command.
pnd build:script private/build-app.sh
This command will update the WordPress version to the latest minor version. It does not use the WP CLI, since that relies on db entries.
NOTE: Use it AFTER building the project with the latest composer state.
pnd build:security-updates public/wordpress
pnd build:security-updates public/wp
There is currently only one webhook command available.
This command will execute a BuildConfig webhook on OpenShift to trigger a build. Succesfully invoking this webhook does not mean your build on OpenShift has succeeded. It simply starts building it. If the build on OpenShift is succesfull it will automagicly start the deployment process there.
If a webhook for a BuildConfig is not yet available use the following oc command to generate him
oc set triggers bc <build-config-name> --from-webhook=true
This command uses the $OPENSHIFT_WEBHOOK environment variable, or you can optionally set it with the following option
There are a few options to override the default repository variables with different ones:
pnd webhook:openshift --webhook="https://some-openshift-generic-webhook.url"
The SSH commands require some additional setup within the repository settings on Bitbucket. Please provide the following information to the repository for these to work:
This command simply tests if we can connect. It uses above defaults, but can be overwritten with other data by specifying the following options:
There are a few options to override the default repository variables with different ones:
pnd ssh:test --user=$SSH_USER_DEVELOPMENT --host=$SSH_HOST_DEVELOPMENT
This command does a few things in this order:
~/builds/<BITBUCKET_PROJECT_KEY>-BLD-<BITBUCKET_BUILD_NUMBER>There are a few options to override the default repository variables with different ones:
pnd ssh:rsync --user=$SSH_USER_DEVELOPMENT --host=$SSH_HOST_DEVELOPMENT
This script is run on the destination server. The command will copy the file through ssh and executes the script from the same folder as the relative path in the clone dir. It performs the following actions:
~/builds/<BITBUCKET_PROJECT_KEY>-BLD-<BITBUCKET_BUILD_NUMBER><path_to_file>There are a few options to override the default repository variables with different ones:
pnd ssh:script private/set-symlinks.sh
This script is run on the destination server. The command will copy a preset symlink template file through ssh and executes the script on the destination server. It performs the following actions:
~/builds/<BITBUCKET_PROJECT_KEY>-BLD-<BITBUCKET_BUILD_NUMBER>/There are a few options to override the default repository variables with different ones:
The following templates are available. In the future more templates might come available. To see all templates currently, use the --list option.
pnd ssh:template --list
pnd ssh:template wp-base-theme-rediscache
pnd ssh:template wp-base-theme-w3tc
pnd ssh:template wp-base-theme-wprocket
pnd ssh:template wp-stock-rediscache
pnd ssh:template wp-stock-w3tc
pnd ssh:template wp-stock-wprocket
This script will clean up some old builds on the production server. By default it will keep the last 5 builds.
There are a few options to override the default repository variables with different ones:
pnd ssh:cleanup --keep=3
Below you will find a basic pipeline for inside your bitbucket projects. It does not use all features listed above, but it gives you an insight in how to get started.
image: proudnerdswp/bitbucket-builder-image:4.0.0 # Make sure we keep using a specific build so this project will continue building even if newer versions of the image are available.
definitions:
steps:
- step: &build
name: Build
script:
#- nvm install 18.4.0 # Install a node version if needed v20.14.0 is already installed by default
#- pnd build:switch-php 8.0
#- pnd build:script private/test-build-script.sh # Build your project using pnd; handles setting file to +x mode
# A basic builds example.
- composer config http-basic.satispress.wp.proudnerds.com $SATISPRESS_TOKEN satispress
- make prod
- pnd build:security-updates public/wp # Update to the latest minor version of WordPress
artifacts: # Defining the artifacts to be passed to each future step(s).
- public/{wordpress,wp}/**
- public/{wp-content,content,app}/themes/**
- public/{wp-content,content,app}/plugins/**
- public/vendor/**
- vendor/**
# Make sure you have set the private BITBUCKET_SSH_KEY_FILE to allow access to the server in Repository Settings->Pipeline->SSH Keys
pipelines:
branches:
develop:
- step: *build
- step:
name: Deploy testing
deployment: test # Make sure you have defined this deployment with variables SSH_USER, SSH_HOST, SSH_PORT
script:
- pnd ssh:rsync # rsync all repo files without .git folders
- pnd ssh:template wp-base-theme-w3tc # set symlinks according to given template
- pnd ssh:cleanup --keep=2 # cleanup old builds and keep latest 2
release/*:
- step: *build
- step:
name: Deploy staging
deployment: staging # Make sure you have defined this deployment with variables SSH_USER, SSH_HOST, SSH_PORT
script:
- pnd ssh:rsync # rsync all repo files without .git folders
- pnd ssh:template wp-base-theme-w3tc # set symlinks according to given template
- pnd ssh:cleanup # cleanup old builds and keep latest 5
main:
- step: *build
- step:
name: Deploy production
deployment: production # Make sure you have defined this deployment with variables SSH_USER, SSH_HOST, SSH_PORT
script:
- pnd ssh:rsync # rsync all repo files without .git folders
- pnd ssh:template wp-base-theme-w3tc # set symlinks according to given template
- pnd ssh:cleanup # cleanup old builds and keep latest 5
When migrating from our Bamboo builds to Bitbucket builds, please check the following:
cd ~/builds/shared && find . -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;Content type
Image
Digest
sha256:0afe262c9…
Size
272.1 MB
Last updated
20 days ago
docker pull proudnerdswp/bitbucket-builder-image:4.2.2