Skip to content

Commit

Permalink
Merge pull request #7 from topfreegames/migrate-go-mod
Browse files Browse the repository at this point in the history
Migrate go mod
  • Loading branch information
flapezoti committed Jan 29, 2021
2 parents e343e95 + fabe347 commit 3636f6f
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 714 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish Docker image
on:
release:
types: [published]
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.15'
- name: Checkout
uses: actions/checkout@v2
- name: Download dependencies
run: go mod download
- name: Run tests
run: make test
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: tfgco/mqtt-history
tag_with_ref: true
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: '1.15'
- name: Checkout
uses: actions/checkout@v2
- name: Download dependencies
run: go mod download
- name: Run tests
run: make test
- name: Install goveralls
run: go get github.com/mattn/goveralls
- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: go run github.com/mattn/goveralls -coverprofile coverage.out -service=github
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ tmp/
*swo
.*swp
.*swo

.idea
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
FROM golang:1.8.3-alpine
FROM golang:1.15-alpine AS build

MAINTAINER TFG Co <backend@tfgco.com>

RUN apk add --no-cache git bash
WORKDIR /src

RUN go get -u github.com/golang/dep/...
COPY vendor ./vendor

ADD . /go/src/github.com/topfreegames/mqtt-history
COPY . .

WORKDIR /go/src/github.com/topfreegames/mqtt-history
RUN dep ensure
RUN go install github.com/topfreegames/mqtt-history
# Build a static binary.
RUN CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -installsuffix cgo -o mqtt-history .

# Verify if the binary is truly static.
RUN ldd /src/mqtt-history 2>&1 | grep -q 'Not a valid dynamic program'

FROM alpine:3.13

COPY --from=build /src/mqtt-history ./mqtt-history
COPY --from=build /src/config ./config

ENV MQTTHISTORY_REDIS_HOST localhost
ENV MQTTHISTORY_REDIS_PORT 6379
Expand Down
Loading

0 comments on commit 3636f6f

Please sign in to comment.