generated from okp4/template-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from okp4/build/docker-image
🐳 Docker build & publish
- Loading branch information
Showing
6 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* | ||
!project.yaml | ||
!src | ||
!proto | ||
!schema.graphql | ||
!package.json | ||
!yarn.lock | ||
!tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,3 +130,13 @@ jobs: | |
dry: True | ||
prettier_options: --check . | ||
prettier_version: 3.0.2 | ||
|
||
lint-dockerfile: | ||
runs-on: ubuntu-22.04 | ||
if: github.actor != 'dependabot[bot]' | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Lint dockerfile (hadolint) | ||
uses: hadolint/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
tags: ["v*"] | ||
|
||
concurrency: | ||
group: publish-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish-docker-images: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: docker_metadata | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=raw,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},value=nightly | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
labels: | | ||
org.opencontainers.image.vendor=OKP4 | ||
- name: Login to Docker registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.DOCKER_REGISTRY_ID }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
- name: Build and publish image(s) | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.docker_metadata.outputs.tags }} | ||
labels: ${{ steps.docker_metadata.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM node:18.16-alpine as build | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package.json . | ||
COPY yarn.lock . | ||
|
||
RUN yarn --frozen-lockfile | ||
|
||
COPY . . | ||
|
||
RUN yarn codegen && yarn build | ||
|
||
FROM onfinality/subql-node-cosmos:v2.8.0 | ||
|
||
EXPOSE 3000 | ||
|
||
WORKDIR /srv/subql | ||
|
||
RUN addgroup -S subql && adduser -S subql -G subql | ||
|
||
USER subql | ||
|
||
COPY --from=build --chown=subql:subql /usr/src/app/dist /srv/subql/dist | ||
COPY --from=build --chown=subql:subql /usr/src/app/proto /srv/subql/proto | ||
COPY --from=build --chown=subql:subql /usr/src/app/schema.graphql /srv/subql/schema.graphql | ||
COPY --from=build --chown=subql:subql /usr/src/app/project.yaml /srv/subql/project.yaml | ||
|
||
CMD ["-f", "/srv/subql"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters