Skip to content

Commit

Permalink
add dockerfile. (initia-labs#19)
Browse files Browse the repository at this point in the history
* add dockerfile.

* clean up.

* change workdir

* expose opinitd directly

* update comments and remove unused copy line

---------

Co-authored-by: beer-1 <[email protected]>
  • Loading branch information
SeUkKim and beer-1 authored Oct 8, 2024
1 parent 89a72c8 commit 86916b3
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Docker

on:
workflow_dispatch:
push:
branches:
- "main"
tags:
- "v*"
paths:
- "**.go"
- "go.mod"
- "go.sum"
pull_request:
branches:
- "main"
paths:
- "**.go"
- "go.mod"
- "go.sum"

env:
REGISTRY: ghcr.io

jobs:
opinitd:
name: opinitd
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

outputs:
tags: ${{ steps.meta.outputs.tags }}

env:
IMAGE_NAME: opinitd

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v4
with:
file: Dockerfile
push: ${{ startsWith(github.ref, 'refs/tags') }} # push image only for tags
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Used for running OPinit bots in a Docker container
#
# Useage:
# $ docker build --tag opinit-bots .

FROM golang:1.23-alpine AS builder

RUN apk add --no-cache g++ make bash

WORKDIR /app
COPY . /app/

RUN make install

FROM alpine:latest

COPY --from=builder /go/bin/opinitd /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/opinitd"]

0 comments on commit 86916b3

Please sign in to comment.