-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from themisir/master
Docker file & CI setup
- Loading branch information
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |