Skip to content

Commit

Permalink
Publish containerised application to github container registry (#104)
Browse files Browse the repository at this point in the history
* chore(approbation): add build workflow
  • Loading branch information
edd authored Jun 30, 2023
1 parent 70fcf78 commit dd26c2c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist
build
LICENSE
*.md
test
.husky
.github
results
assets
.dockerignore
.npmignore
.gitignore

2 changes: 1 addition & 1 deletion .github/workflows/01-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
node-version:
- 18.x
- 19.x
- 20.x
steps:
- name: Check out code
uses: actions/checkout@v3
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/02-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Package approbation image

"on":
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v3
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export to local Docker
uses: docker/build-push-action@v3
with:
push: false
load: true
tags: vegaprotocol/approbation:local

- name: Sanity check docker image
run: |
docker run --rm vegaprotocol/approbation:local version || docker run --rm vegaprotocol/approbation:local
- name: Build and push to GitHub Docker registry
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/vegaprotocol/approbation:latest
ghcr.io/vegaprotocol/approbation:${{github.ref_name}}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Build with node 18
FROM node:18-bullseye-slim AS build
WORKDIR /app
COPY . .
ENV NODE_ENV=production
RUN npm install --omit=dev --no-audit

## Run in distroless
FROM astefanutti/scratch-node:18.10.0
COPY --from=build /app /app
WORKDIR /app
ENTRYPOINT ["node", "bin/approbation.js"]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test:ci": "tape test/*.js",
"test": "tape test/*.js | tap-arc",
"lint": "standard **/*.js",
"setup": "husky install"
"setup": "husky install",
"build": "pkg ."
},
"repository": {
"type": "git",
Expand Down

0 comments on commit dd26c2c

Please sign in to comment.