Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker)!: include support for buildx #50

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 0000-BASE
FROM docker:latest
ARG SRC_DIR='.'
RUN apk update && apk upgrade && apk add nodejs npm git
RUN apk update && apk upgrade && apk add nodejs npm git curl
WORKDIR /opt/app
COPY ${SRC_DIR}/package.json /opt/app/
RUN npm install
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Run `npm i --save-dev @codedependant/semantic-release-docker` to install this se

### Docker registry authentication

The `docker registry` authentication set via environment variables. It is not required, and if
Authentication to a `docker registry` is set via environment variables. It is not required, and if
omitted, it is assumed the docker daemon is already authenticated with the target registry.

### Environment variables
Expand All @@ -48,6 +48,7 @@ omitted, it is assumed the docker daemon is already authenticated with the targe
| `dockerImage` | _Optional_. The name of the image to release. | [String][] | Parsed from package.json `name` property |
| `dockerRegistry` | _Optional_. The hostname and port used by the the registry in format `hostname[:port]`. Omit the port if the registry uses the default port | [String][] | `null` (dockerhub) |
| `dockerProject` | _Optional_. The project or repository name to publish the image to | [String][] | For scoped packages, the scope will be used, otherwise `null` |
| `dockerPlatform` | _Optional_. A list of target platofmrs to build for. If specified, [buildx][] Will be used to generate the final images | [Array][]<[String][]> | `null` (default docker build behavior) |
| `dockerFile` | _Optional_. The path, relative to `$PWD` to a Docker file to build the target image with | [String][] | `Dockerfile` |
| `dockerContext` | _Optional_. A path, relative to `$PWD` to use as the build context A | [String][] | `.` |
| `dockerLogin` | _Optional_. Set to false it by pass docker login if the docker daemon is already authorized | [String][] | `true` |
Expand All @@ -59,6 +60,19 @@ omitted, it is assumed the docker daemon is already authenticated with the targe
| `dockerBuildFlags` | _Optional_. An object containing additional flags to the `docker build` command. Values can be strings or an array of strings | [Object][] | `{}` |
| `dockerBuildCacheFrom` | _Optional_. A list of external cache sources. See [--cache-from][] | [String][] | [Array][]<[String][]> | |


### BuildX Support

Version 5.X includes initial and experimental support for multi-platform images via the [buildx][] plugin.
This plugin assumes that the docker daemon and buildx have already been setup correctly.
Platform specific builder must be setup and selected for this plugin to utilize [buildx][]

> [!WARNING]
>
> When using buildx via the dockerPlatform option, images are not kept locally
> and normal docker commands targeting those images will not work.
> The `dockerVerifyCmd` behavior will only trigger a build and is unable to execute local command

### Build Arguments

By default several build arguments will be included when the docker images is being built.
Expand Down Expand Up @@ -180,6 +194,7 @@ module.exports = {
dockerFile: 'Dockerfile',
dockerRegistry: 'quay.io',
dockerProject: 'codedependant',
dockerPlatform: ['linux/amd64', 'linux/arm64']
dockerBuildFlags: {
pull: null
, target: 'release'
Expand Down Expand Up @@ -209,7 +224,7 @@ Alternatively, using global options w/ root configuration
"dockerFile": "Dockerfile",
"dockerRegistry": "quay.io",
"dockerArgs": {
"GITHUB_TOKEN": true
"GITHUB_TOKEN": null
, "SOME_VALUE": '{{git_sha}}'
}
}
Expand Down Expand Up @@ -283,3 +298,4 @@ $ openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -o
[Object]: https://mdn.io/object
[Number]: https://mdn.io/number
[--cache-from]: https://docs.docker.com/engine/reference/commandline/build/#cache-from
[buildx]: https://docs.docker.com/reference/cli/docker/buildx/build
10 changes: 10 additions & 0 deletions compose/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ services:
volumes:
- $PWD/compose/certs:/certs
- $PWD/compose/auth:/auth
docker:
privileged: true
image: docker:25-dind
environment:
DOCKER_TLS_CERTDIR: ''
DOCKER_BUILDKIT: 1
command: [
"--insecure-registry=registry:5000"
]

40 changes: 20 additions & 20 deletions compose/certs/server.crt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDtTCCAp2gAwIBAgIUFhtb0Us9cq7joYrHWDjD+UG9m2UwDQYJKoZIhvcNAQEL
BQAwajELMAkGA1UEBhMCVVMxEjAQBgNVBAgMCXdpc2NvbnNpbjEMMAoGA1UEBwwD
bWtlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFjAUBgNVBAMM
DXJlZ2lzdHJ5OjUwMDAwHhcNMjIxMjE5MTQyODI0WhcNMjMxMjE5MTQyODI0WjBq
MQswCQYDVQQGEwJVUzESMBAGA1UECAwJd2lzY29uc2luMQwwCgYDVQQHDANta2Ux
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEWMBQGA1UEAwwNcmVn
aXN0cnk6NTAwMDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPUrJOXq
mdWW0/zCoxiuwuYm3MZSVtO7EKl/HqPiN2Z8Qk0Xo6SaycTRv2+hmXMLEm2UuzOb
8Dk+uQmBi5W6rmv9ovjcBJcEp6UJ47UMT/ZZGojRxUczGobvTziM1zzWe/KnDQ/J
z1M4TBVAsMTIvzyUhu1BljTm3iG6BBLfCWKm05ec5+kVRghNh3YQmeRGJsLFHG75
/ZGP5yr97bZxe8BuY0Sa8K1urWsrFf4k0Zog3u7bx8lFgsp0n6QgzcOxlQeFSB7i
htPGla5ui1pdGo1gfsqY107hK3QPAGoellk/z7Hd9fUC15RQLCR8csINZXPjfWRj
PtG9Z0Iz40VcYtsCAwEAAaNTMFEwHQYDVR0OBBYEFIMQd/iiAcwmb2Khb97G+zcJ
M4CXMB8GA1UdIwQYMBaAFIMQd/iiAcwmb2Khb97G+zcJM4CXMA8GA1UdEwEB/wQF
MAMBAf8wDQYJKoZIhvcNAQELBQADggEBAAzy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UEIYKR7FG9fmedcCqdz+JKQoR/gBFAm2P2XXZQUcYc3MdhB14l8C
AwEAAaNTMFEwHQYDVR0OBBYEFCdItgsrVNAQxNOxJ1oLK0n4feCbMB8GA1UdIwQY
MBaAFCdItgsrVNAQxNOxJ1oLK0n4feCbMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
hvcNAQELBQADggEBAE1jZt3Mgv2FkTncd5GoXFfH7zJp6d/Yq1JTckpdDLndviV/
j+q5cK1xxMFLMqqEbya8qMfrc7DeyZCTZiFZQ0BiQfR6zKm83ZsJ16aEaR8zVvRu
gdfrj9jlWZvTYpWM5G6bPTMGtcYwPBjPd/zSR+xbMSlHk5JeCSE/17evSc3Jd6i9
m7OR0SHfQD82us5VZEfZKqXUwn9frE0cLJ0PuEPOQq5914QBzrr99UWF6XMeURD0
9MZP+y9MhNK5ltTxI4wIhVNbyPFV+9g0Xfbfo8yV5evN0veUlMHwVAfm4xhMrqoW
z+kBlf7dGTzAHdqRI2KhI1nA3mrykaCe/WX2wuU=
-----END CERTIFICATE-----
52 changes: 26 additions & 26 deletions compose/certs/server.key
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD1KyTl6pnVltP8
wqMYrsLmJtzGUlbTuxCpfx6j4jdmfEJNF6OkmsnE0b9voZlzCxJtlLszm/A5PrkJ
gYuVuq5r/aL43ASXBKelCeO1DE/2WRqI0cVHMxqG7084jNc81nvypw0Pyc9TOEwV
QLDEyL88lIbtQZY05t4hugQS3wliptOXnOfpFUYITYd2EJnkRibCxRxu+f2Rj+cq
/e22cXvAbmNEmvCtbq1rKxX+JNGaIN7u28fJRYLKdJ+kIM3DsZUHhUge4obTxpWu
botaXRqNYH7KmNdO4St0DwBqHpZZP8+x3fX1AteUUCwkfHLCDWVz431kYz7RvWdC
M+NFXGLbAgMBAAECggEAWC/AMnlsA0GhGAKU8vx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nQ3sIHkh2J7ZvDycwKBgQDAtumOHJT7tpnVYeGLkI4yTh57J9SY8rR2
fw2VDoGDBt72q+vXe3dK5rALdBEw6u9OH/BH/GbeAU3vLkoPrCMDTb3gFGLKPWDF
5D6PPjhybyCgCaXA7rabfgKKmCUp5LeV9uVz2WADPP41tJVZUHHxsjxXIGuFSvi1
8UB5oiMZZQKBgGlQqn+DxKB2BadbR69nAgB0i8ApXxTWicqgPtiM28M1vWJepwLN
U/wlO7G/MxCeeQWqcq3D45b1RQlsO9/rMyIcLYWh48IFePPRzsznW6fjP03HP1ok
cV7OOia7BDjA537nABlK4a4plD276bYU10o9Xa6XjL8sZWevx9zLwa9hAoGAITRi
8ZWDJgvEXbvLvNxfY9OJ9PZb7y6CYZhqorApKIZajG366NnhKAqvconBHIieSvu9
zulyX/Yhk4CKSkECl2MhwCZDD02cCvzUuqGh4DW9jVWcNa3r0MbZcT/dx2YdK72q
s1dU77nmoyJGSWlO+LIZK3nujLzqNY8n6M1C9vECgYB01R0KZZxYmHRRoLSywWqg
1XHGk7YDXuWW7BNc4Ury023od6W+C07XEmw0rN7deubLZ+8oa7NEPKJid0K1q4HZ
f8oGTIYA0y7lLjCbYNhHafjr/iOyY/ElaHAKHtnD/EGwP2V3JLw4VTm6Jx4HtR9U
hpS4211uPw+qovrzCulLuA==
-----END PRIVATE KEY-----
10 changes: 1 addition & 9 deletions compose/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
version: '2.4'
services:
docker:
privileged: true
image: docker:stable-dind
environment:
DOCKER_TLS_CERTDIR: ''
command: [
"--insecure-registry=registry:5000"
]

semantic-release:
build:
context: ../
environment:
DOCKER_HOST: tcp://docker:2375
DOCKER_BUILDKIT: 1
TEST_DOCKER_REGISTRY: registry:5000
command: npm run tap
depends_on:
Expand Down
2 changes: 2 additions & 0 deletions lib/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async function buildConfig(build_id, config, context) {
, dockerRegistry: registry = null
, dockerLogin: login = true
, dockerImage: image
, dockerPlatform: platform = null
, dockerPublish: publish = true
, dockerContext = '.'
, dockerVerifyCmd: verifycmd = null
Expand Down Expand Up @@ -75,5 +76,6 @@ async function buildConfig(build_id, config, context) {
, network: network
, quiet: typeCast(quiet) === true
, clean: typeCast(clean) === true
, platform: array.toArray(platform)
}
}
Loading
Loading