Skip to content

Commit 86916b3

Browse files
SeUkKimbeer-1
andauthored
add dockerfile. (#19)
* add dockerfile. * clean up. * change workdir * expose opinitd directly * update comments and remove unused copy line --------- Co-authored-by: beer-1 <[email protected]>
1 parent 89a72c8 commit 86916b3

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.github/workflows/docker.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Docker
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "main"
8+
tags:
9+
- "v*"
10+
paths:
11+
- "**.go"
12+
- "go.mod"
13+
- "go.sum"
14+
pull_request:
15+
branches:
16+
- "main"
17+
paths:
18+
- "**.go"
19+
- "go.mod"
20+
- "go.sum"
21+
22+
env:
23+
REGISTRY: ghcr.io
24+
25+
jobs:
26+
opinitd:
27+
name: opinitd
28+
runs-on: ubuntu-latest
29+
30+
permissions:
31+
contents: read
32+
packages: write
33+
34+
outputs:
35+
tags: ${{ steps.meta.outputs.tags }}
36+
37+
env:
38+
IMAGE_NAME: opinitd
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
44+
- name: Log in to the Container registry
45+
uses: docker/login-action@v2
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Extract metadata (tags, labels) for Docker
52+
id: meta
53+
uses: docker/metadata-action@v4
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
56+
57+
- name: Build and push
58+
uses: docker/build-push-action@v4
59+
with:
60+
file: Dockerfile
61+
push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Used for running OPinit bots in a Docker container
2+
#
3+
# Useage:
4+
# $ docker build --tag opinit-bots .
5+
6+
FROM golang:1.23-alpine AS builder
7+
8+
RUN apk add --no-cache g++ make bash
9+
10+
WORKDIR /app
11+
COPY . /app/
12+
13+
RUN make install
14+
15+
FROM alpine:latest
16+
17+
COPY --from=builder /go/bin/opinitd /usr/local/bin/
18+
19+
ENTRYPOINT ["/usr/local/bin/opinitd"]

0 commit comments

Comments
 (0)