Skip to content

Commit

Permalink
chore(container): add initial container wrapper and build action
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiehrhardt authored and AdeAttwood committed Sep 25, 2023
1 parent 8806efc commit c538d3c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/container-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: container build
on:
push:
tags:
- '**'
branches:
- '**'
- '!master'
schedule:
- cron: '0 0 * * *'
jobs:
container-build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: commitlint/commitlint
tags: |
type=semver,pattern={{version}}
type=edge,branch=master
type=ref,event=branch
type=sha,prefix=,format=short
- name: Build and push container image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.ci
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# disable arm build for now, because of https://github.com/nodejs/docker-node/issues/1335
platforms: linux/amd64 #,linux/arm64
30 changes: 30 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM docker.io/library/node:18-buster AS builder
WORKDIR /src
COPY . ./
RUN yarn install && \
yarn run build && \
# Commit lint CLI packages
npm pack @commitlint/cli && \
npm pack @commitlint/config-validator && \
npm pack @commitlint/ensure && \
npm pack @commitlint/execute-rule && \
npm pack @commitlint/format && \
npm pack @commitlint/is-ignored && \
npm pack @commitlint/lint && \
npm pack @commitlint/load && \
npm pack @commitlint/message && \
npm pack @commitlint/parse && \
npm pack @commitlint/read && \
npm pack @commitlint/resolve-extends && \
npm pack @commitlint/rules && \
npm pack @commitlint/to-lines && \
npm pack @commitlint/top-level && \
npm pack @commitlint/types && \
# Default commitlint config
npm pack @commitlint/config-conventional

FROM docker.io/library/node:18-buster
COPY --from=builder /src/*.tgz ./
RUN npm install -g *.tgz && \
rm -rf *.tgz
ENTRYPOINT ["commitlint"]
File renamed without changes.
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: '3'
services:
commitlint:
build: .
build:
context: .
dockerfile: Dockerfile.dev
image: marionebl/commitlint-cubicle
ports:
- '8443:8443'
Expand Down
18 changes: 18 additions & 0 deletions docs/guides-ci-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,30 @@ workflows:
## GitLab CI
```yaml
stages: ["lint","build","test"]
lint:commit:
image: registry.hub.docker.com/library/node:alpine
stage: lint
before_script:
- apk add --no-cache git
- npm install --save-dev @commitlint/config-conventional @commitlint/cli
script:
- echo "${CI_COMMIT_MESSAGE}" | npx commitlint
```
## GitLab CI with pre-build container
```yaml
stages: ["lint","build","test"]
lint:commit:
image:
name: registry.hub.docker.com/commitlint/commitlint:latest
entrypoint: [""]
stage: lint
script:
- echo "${CI_COMMIT_MESSAGE}" | commitlint
```
### 3rd party integrations
#### [Codemagic](https://codemagic.io/)
Expand Down

0 comments on commit c538d3c

Please sign in to comment.