Skip to content

Commit 00f883c

Browse files
committed
Add a docker build
1 parent a78d658 commit 00f883c

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/docker.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Docker image
2+
# Run the tasks on every push
3+
on: push
4+
jobs:
5+
build_push_api:
6+
name: Build and push execution environment
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check out the repository
10+
uses: actions/checkout@v2
11+
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v1
14+
15+
- name: Set up Docker layer caching
16+
uses: actions/cache@v2
17+
with:
18+
path: /tmp/.buildx-cache
19+
key: ${{ runner.os }}-buildx-${{ github.sha }}
20+
restore-keys: |
21+
${{ runner.os }}-buildx-
22+
- name: Login to GitHub Container Registry
23+
uses: docker/login-action@v1
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Calculate metadata for image
30+
id: image-meta
31+
uses: docker/metadata-action@v3
32+
with:
33+
images: ghcr.io/stackhpc/os-capacity
34+
# Produce the branch name or tag and the SHA as tags
35+
tags: |
36+
type=ref,event=branch
37+
type=ref,event=tag
38+
type=sha,prefix=
39+
- name: Build and push image
40+
uses: docker/build-push-action@v2
41+
with:
42+
context: .
43+
push: true
44+
tags: ${{ steps.image-meta.outputs.tags }}
45+
labels: ${{ steps.image-meta.outputs.labels }}
46+
cache-from: type=local,src=/tmp/.buildx-cache
47+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
48+
49+
# Temp fix
50+
# https://github.com/docker/build-push-action/issues/252
51+
# https://github.com/moby/buildkit/issues/1896
52+
# https://github.com/docker/buildx/pull/535
53+
- name: Move cache
54+
run: |
55+
rm -rf /tmp/.buildx-cache
56+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update && apt-get upgrade -y && apt-get install python3-pip tini -y && apt-get clean
4+
5+
COPY . /opt/os-capacity
6+
RUN pip install -U -e /opt/os-capacity
7+
8+
ENTRYPOINT ["tini", "-g", "--"]
9+
CMD ["python3", "/opt/os-capacity/os_capacity/prometheus.yaml"]

0 commit comments

Comments
 (0)