Skip to content

Commit 7ac474f

Browse files
committed
feat: init docker image and github actions
1 parent d2d6dd2 commit 7ac474f

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
version: 2
77
updates:
8+
- package-ecosystem: "docker" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"
12+
813
- package-ecosystem: "github-actions"
914
directory: "/"
1015
schedule:

.github/workflows/build.yml

+58
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
branches:
1111
- '**'
1212

13+
env:
14+
DOCKERHUB_SLUG: openbayes/tvm-cn
15+
GHCR_SLUG: ghcr.io/hyperai/tvm-cn
16+
1317
jobs:
1418
build-n-deploy:
1519
runs-on: ubuntu-latest
@@ -28,3 +32,57 @@ jobs:
2832

2933
- name: Build Docusaurus
3034
run: yarn build
35+
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v2
38+
39+
- name: Set up Docker Buildx
40+
id: buildx
41+
uses: docker/setup-buildx-action@v2
42+
43+
- name: Available platforms
44+
run: echo ${{ steps.buildx.outputs.platforms }}
45+
46+
- name: Log in to Docker Hub
47+
if: github.event_name != 'pull_request'
48+
uses: docker/login-action@v2
49+
with:
50+
username: ${{ secrets.DOCKERHUB_USERNAME }}
51+
password: ${{ secrets.DOCKERHUB_TOKEN }}
52+
53+
- name: Login to GitHub Container Registry
54+
if: github.event_name != 'pull_request'
55+
uses: docker/login-action@v2
56+
with:
57+
registry: ghcr.io
58+
username: ${{ github.repository_owner }}
59+
password: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Docker meta
62+
id: meta
63+
uses: docker/metadata-action@v4
64+
with:
65+
images: |
66+
${{ env.DOCKERHUB_SLUG }}
67+
${{ env.GHCR_SLUG }}
68+
tags: |
69+
type=edge
70+
type=schedule
71+
type=ref,event=branch
72+
type=ref,event=pr
73+
type=semver,pattern={{version}}
74+
type=semver,pattern={{major}}.{{minor}}
75+
type=semver,pattern={{major}}
76+
type=sha
77+
78+
- name: Build and push
79+
uses: docker/bake-action@v2
80+
with:
81+
files: |
82+
./docker-bake.hcl
83+
${{ steps.meta.outputs.bake-file }}
84+
targets: build-all
85+
push: ${{ github.event_name != 'pull_request' }}
86+
set: |
87+
*.cache-from=type=gha
88+
*.cache-to=type=gha,mode=max

Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:alpine
2+
3+
ADD nginx.conf /etc/nginx/conf.d/default.conf
4+
ADD build/ /usr/share/nginx/html/

docker-bake.hcl

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
variable "DEFAULT_TAG" {
2+
default = ["openbayes/tvm-cn:local"]
3+
}
4+
5+
# Special target: https://github.com/docker/metadata-action#bake-definition
6+
target "docker-metadata-action" {
7+
tags = "${DEFAULT_TAG}"
8+
}
9+
10+
# Default target if none specified
11+
group "default" {
12+
targets = ["build-local"]
13+
}
14+
15+
target "build" {
16+
inherits = ["docker-metadata-action"]
17+
}
18+
19+
target "build-local" {
20+
inherits = ["build"]
21+
output = ["type=docker"]
22+
}
23+
24+
target "build-all" {
25+
inherits = ["build"]
26+
platforms = [
27+
"linux/amd64",
28+
]
29+
}

nginx.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
5+
charset utf-8;
6+
#charset koi8-r;
7+
#access_log /var/log/nginx/log/host.access.log main;
8+
9+
root /usr/share/nginx/html;
10+
11+
location / {
12+
index index.html index.htm;
13+
}
14+
15+
location /favicon.ico { return 301 /img/favicon.png; }
16+
location /favicon.png { return 301 /img/favicon.png; }
17+
18+
error_page 401 403 404 500 502 503 504 /404.html;
19+
}

0 commit comments

Comments
 (0)