Skip to content

Commit

Permalink
Merge pull request #1 from themisir/master
Browse files Browse the repository at this point in the history
Docker file & CI setup
  • Loading branch information
alvanrahimli authored Aug 15, 2021
2 parents b458cdb + 27cc289 commit 4491f25
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
create:
tags:
- v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.13.1"
- name: Build
run: go build -o dots-server
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload release
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dots-server
asset_name: dots-server-linux
asset_content_type: application/octet-stream

publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
# source: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
- name: Build the image
run: docker buildx build --push --tag dotsorg/dots-server:latest .
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM alpine AS base
ENV PORT=80
WORKDIR /app
EXPOSE 80

FROM golang:1.16-alpine AS deps
WORKDIR /src
COPY go.mod .
COPY go.sum .
RUN go mod download
RUN apk update \
&& apk add --no-cache git \
&& apk add --no-cache ca-certificates \
&& apk add --update gcc musl-dev \
&& update-ca-certificates

FROM deps AS build
WORKDIR /src
COPY . .
RUN GOOS=linux CGO_ENABLED=1 GOARCH=amd64 go build -o /app/server

FROM base AS final
WORKDIR /app
COPY --from=build /app/server .
ENTRYPOINT ["/app/server"]

0 comments on commit 4491f25

Please sign in to comment.