mirror of
https://github.com/N0rthernL1ghts/wordpress.git
synced 2024-11-27 02:11:20 +01:00
Add cron optimized image
This commit is contained in:
parent
0cb7952020
commit
4e6e2aa78e
7
.github/workflows/image.yml
vendored
7
.github/workflows/image.yml
vendored
|
@ -43,8 +43,13 @@ jobs:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
wait-interval: 20
|
wait-interval: 20
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push WordPress Web image
|
||||||
uses: docker/bake-action@v5.10.0
|
uses: docker/bake-action@v5.10.0
|
||||||
with:
|
with:
|
||||||
files: build/docker-bake.hcl
|
files: build/docker-bake.hcl
|
||||||
push: true
|
push: true
|
||||||
|
- name: Build and push WordPress Cron image
|
||||||
|
uses: docker/bake-action@v5.10.0
|
||||||
|
with:
|
||||||
|
files: build/docker-bake-cron.hcl
|
||||||
|
push: true
|
12
Dockerfile.cron
Normal file
12
Dockerfile.cron
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
ARG WP_VERSION=6.1.0
|
||||||
|
FROM ghcr.io/n0rthernl1ghts/wordpress:${WP_VERSION}
|
||||||
|
|
||||||
|
# Disable all s6 services except for svc-crond and init-wpconfig-verify
|
||||||
|
RUN set -eux \
|
||||||
|
&& bash -c "rm -rf /etc/s6-overlay/s6-rc.d/{svc-unitd,init-unitd-configure,init-verify-wordpress,init-install-wordpress,init-install-resources,init-webuser-permissions,init-wpcontent} \
|
||||||
|
&& rm -rf /etc/s6-overlay/s6-rc.d/user/contents.d/{svc-unitd,init-unitd-configure,init-verify-wordpress,init-install-wordpress,init-install-resources,init-webuser-permissions,init-wpcontent} \
|
||||||
|
&& rm -rf /etc/s6-overlay/s6-rc.d/svc-crond/dependencies.d/{init-install-wordpress,svc-unitd}"
|
||||||
|
|
||||||
|
|
||||||
|
ENV CRON_ENABLED=true
|
||||||
|
|
231
build/docker-bake-cron.hcl
Normal file
231
build/docker-bake-cron.hcl
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
group "default" {
|
||||||
|
targets = [
|
||||||
|
"6_2_0",
|
||||||
|
"6_2_1",
|
||||||
|
"6_2_2",
|
||||||
|
"6_3_0",
|
||||||
|
"6_3_1",
|
||||||
|
"6_3_2",
|
||||||
|
"6_4_0",
|
||||||
|
"6_4_1",
|
||||||
|
"6_4_2",
|
||||||
|
"6_4_3",
|
||||||
|
"6_5_0",
|
||||||
|
"6_5_2",
|
||||||
|
"6_5_3",
|
||||||
|
"6_5_4",
|
||||||
|
"6_5_5",
|
||||||
|
"6_6_0",
|
||||||
|
"6_6_1",
|
||||||
|
"6_6_2"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "build-dockerfile" {
|
||||||
|
dockerfile = "Dockerfile.cron"
|
||||||
|
}
|
||||||
|
|
||||||
|
target "build-platforms" {
|
||||||
|
platforms = ["linux/amd64", "linux/aarch64"]
|
||||||
|
}
|
||||||
|
|
||||||
|
target "build-common" {
|
||||||
|
pull = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "REGISTRY_CACHE" {
|
||||||
|
default = "ghcr.io/n0rthernl1ghts/wordpress-cron-cache"
|
||||||
|
}
|
||||||
|
|
||||||
|
######################
|
||||||
|
# Define the functions
|
||||||
|
######################
|
||||||
|
|
||||||
|
# Get the arguments for the build
|
||||||
|
function "get-args" {
|
||||||
|
params = [version]
|
||||||
|
result = {
|
||||||
|
WP_VERSION = version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the cache-from configuration
|
||||||
|
function "get-cache-from" {
|
||||||
|
params = [version]
|
||||||
|
result = [
|
||||||
|
"type=registry,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the cache-to configuration
|
||||||
|
function "get-cache-to" {
|
||||||
|
params = [version]
|
||||||
|
result = [
|
||||||
|
"type=registry,mode=max,ref=${REGISTRY_CACHE}:${sha1("${version}-${BAKE_LOCAL_PLATFORM}")}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get list of image tags and registries
|
||||||
|
# Takes a version and a list of extra versions to tag
|
||||||
|
# eg. get-tags("6.2.0", ["6", "6.2", "latest"])
|
||||||
|
function "get-tags" {
|
||||||
|
params = [version, extra_versions]
|
||||||
|
result = concat(
|
||||||
|
[
|
||||||
|
"ghcr.io/n0rthernl1ghts/wordpress-cron:${version}"
|
||||||
|
],
|
||||||
|
flatten([
|
||||||
|
for extra_version in extra_versions : [
|
||||||
|
"ghcr.io/n0rthernl1ghts/wordpress-cron:${extra_version}"
|
||||||
|
]
|
||||||
|
])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################
|
||||||
|
# Define the build targets
|
||||||
|
##########################
|
||||||
|
|
||||||
|
target "6_2_0" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.2.0")
|
||||||
|
cache-to = get-cache-to("6.2.0")
|
||||||
|
tags = get-tags("6.2.0", [])
|
||||||
|
args = get-args("6.2.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_2_1" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.2.1")
|
||||||
|
cache-to = get-cache-to("6.2.1")
|
||||||
|
tags = get-tags("6.2.1", [])
|
||||||
|
args = get-args("6.2.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_2_2" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.2.2")
|
||||||
|
cache-to = get-cache-to("6.2.2")
|
||||||
|
tags = get-tags("6.2.2", ["6.2"])
|
||||||
|
args = get-args("6.2.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_3_0" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.3.0")
|
||||||
|
cache-to = get-cache-to("6.3.0")
|
||||||
|
tags = get-tags("6.3.0", [])
|
||||||
|
args = get-args("6.3.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_3_1" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.3.1")
|
||||||
|
cache-to = get-cache-to("6.3.1")
|
||||||
|
tags = get-tags("6.3.1", [])
|
||||||
|
args = get-args("6.3.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_3_2" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.3.2")
|
||||||
|
cache-to = get-cache-to("6.3.2")
|
||||||
|
tags = get-tags("6.3.2", [])
|
||||||
|
args = get-args("6.3.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_4_0" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.4.0")
|
||||||
|
cache-to = get-cache-to("6.4.0")
|
||||||
|
tags = get-tags("6.4.0", [])
|
||||||
|
args = get-args("6.4.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_4_1" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.4.1")
|
||||||
|
cache-to = get-cache-to("6.4.1")
|
||||||
|
tags = get-tags("6.4.1", [])
|
||||||
|
args = get-args("6.4.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_4_2" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.4.2")
|
||||||
|
cache-to = get-cache-to("6.4.2")
|
||||||
|
tags = get-tags("6.4.2", [])
|
||||||
|
args = get-args("6.4.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_4_3" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.4.3")
|
||||||
|
cache-to = get-cache-to("6.4.3")
|
||||||
|
tags = get-tags("6.4.3", ["6.4"])
|
||||||
|
args = get-args("6.4.3")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_5_0" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.5.0")
|
||||||
|
cache-to = get-cache-to("6.5.0")
|
||||||
|
tags = get-tags("6.5.0", [])
|
||||||
|
args = get-args("6.5.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_5_2" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.5.2")
|
||||||
|
cache-to = get-cache-to("6.5.2")
|
||||||
|
tags = get-tags("6.5.2", [])
|
||||||
|
args = get-args("6.5.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_5_3" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.5.3")
|
||||||
|
cache-to = get-cache-to("6.5.3")
|
||||||
|
tags = get-tags("6.5.3", [])
|
||||||
|
args = get-args("6.5.3")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_5_4" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.5.4")
|
||||||
|
cache-to = get-cache-to("6.5.4")
|
||||||
|
tags = get-tags("6.5.4", [])
|
||||||
|
args = get-args("6.5.4")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_5_5" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.5.5")
|
||||||
|
cache-to = get-cache-to("6.5.5")
|
||||||
|
tags = get-tags("6.5.5", ["6.5"])
|
||||||
|
args = get-args("6.5.5")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_6_0" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.6.0")
|
||||||
|
cache-to = get-cache-to("6.6.0")
|
||||||
|
tags = get-tags("6.6.0", [])
|
||||||
|
args = get-args("6.6.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_6_1" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.6.1")
|
||||||
|
cache-to = get-cache-to("6.6.1")
|
||||||
|
tags = get-tags("6.6.1", [])
|
||||||
|
args = get-args("6.6.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
target "6_6_2" {
|
||||||
|
inherits = ["build-dockerfile", "build-platforms", "build-common"]
|
||||||
|
cache-from = get-cache-from("6.6.2")
|
||||||
|
cache-to = get-cache-to("6.6.2")
|
||||||
|
tags = get-tags("6.6.2", ["6", "6.6", "latest"])
|
||||||
|
args = get-args("6.6.2")
|
||||||
|
}
|
|
@ -113,12 +113,11 @@ services:
|
||||||
cron:
|
cron:
|
||||||
extends:
|
extends:
|
||||||
service: wordpress
|
service: wordpress
|
||||||
|
image: ghcr.io/n0rthernl1ghts/wordpress-cron:6.6.2
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
memory: 512M # Limit the memory for the cron job to 512 MB. This is a good practice to avoid memory leaks.
|
memory: 512M # Limit the memory for the cron job to 512 MB. This is a good practice to avoid memory leaks.
|
||||||
environment:
|
|
||||||
CRON_ENABLED: "true"
|
|
||||||
|
|
||||||
# Redis is optional, but it works really well for caching. If removed, please update x-wordpress-configuration-env
|
# Redis is optional, but it works really well for caching. If removed, please update x-wordpress-configuration-env
|
||||||
cache:
|
cache:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user