Skip to content

Commit

Permalink
Merge pull request #1 from traPtitech/docker
Browse files Browse the repository at this point in the history
build docker image
  • Loading branch information
wtks authored Jun 4, 2020
2 parents 0affabe + 17289ab commit eff8c72
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.idea
.dockerignore
.gitignore
.git
.github
Dockerfile
LICENSE
README.md
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- v*

env:
IMAGE_REPO: traptitech/conoha_exporter
IMAGE_NAME: conoha-exporter

jobs:
build:
name: Build
Expand All @@ -21,3 +25,20 @@ jobs:
uses: goreleaser/goreleaser-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
image:
name: Docker Image
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_TAG env
run: echo ::set-env name=IMAGE_TAG::$(echo ${GITHUB_REF:11})
- uses: actions/checkout@v2
- name: Login GitHub Registry
run: docker login docker.pkg.github.com -u traPtitech -p ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
run: docker build -t docker.pkg.github.com/${IMAGE_REPO}/${IMAGE_NAME}:$IMAGE_TAG .
- name: Push image to GitHub Registry
run: docker push docker.pkg.github.com/${IMAGE_REPO}/${IMAGE_NAME}:$IMAGE_TAG
- name: Push image to GitHub Registry (latest)
run: |
docker tag docker.pkg.github.com/${IMAGE_REPO}/${IMAGE_NAME}:$IMAGE_TAG docker.pkg.github.com/${IMAGE_REPO}/${IMAGE_NAME}:latest
docker push docker.pkg.github.com/${IMAGE_REPO}/${IMAGE_NAME}:latest
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.14-alpine AS build
RUN apk add --update --no-cache git
WORKDIR /src
COPY ./go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /conoha_exporter

FROM alpine:3.11
WORKDIR /app

RUN apk add --update ca-certificates openssl && \
update-ca-certificates && \
rm -rf /var/cache/apk/*

EXPOSE 9330

COPY --from=build /conoha_exporter ./

ENTRYPOINT ./conoha_exporter

0 comments on commit eff8c72

Please sign in to comment.