Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
k-matsuzawa committed Sep 25, 2022
1 parent 2a1c680 commit 698332c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/create-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Docker Image

on:
push:
tags:
- 'v*'
pull_request:
types: [opened, reopened, synchronize]

env:
IMAGE_BASE_NAME: "ghcr.io/${{ github.repository_owner }}/go-base"

jobs:
build-image:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: hadolint/hadolint-action@v2.1.0
with:
dockerfile: ./Dockerfile
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: name=${{env.IMAGE_BASE_NAME}}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=tag
type=semver,pattern={{raw}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER_NAME }}
password: ${{ secrets.CR_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM --platform=$TARGETPLATFORM golang:1.18.6-alpine3.15

ARG CFDGO_VERSION=v0.4.3
RUN apk update && apk add --no-cache alpine-sdk git cmake

WORKDIR /workspace
RUN git clone https://github.com/cryptogarageinc/cfd-go -b $CFDGO_VERSION --depth 1 \
&& cd cfd-go \
&& ./tools/shared_simple_build.sh \
&& go build && ./go_test.sh && go clean -testcache \
&& cd build && make install && cd .. \
&& cd .. && rm -rf cfd-go
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# go-base-dockerfile
# go-base-dockerfile

## build

docker buildx build [--platform <target platform>] [-t <tag>] .

0 comments on commit 698332c

Please sign in to comment.