Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

.dockerignore
.env
.env.example
.env.*
.git
.gitignore

Dockerfile
Dockerfile.dev
Dockerfile.*
docker-compose.yml

log/*
Expand All @@ -17,3 +17,8 @@ tmp/*
!tmp/.keep

.air.conf

.github
.vscode

README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Essential checks
name: CI
on:
push:
branches:
Expand All @@ -15,24 +15,31 @@ jobs:
- name: Run GolangCI-Lint Action
uses: actions-contrib/golangci-lint@v1
with:
args: run --exclude-use-default
args: run ./... --exclude-use-default
test:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@master
- name: docker-compose version
run: docker-compose --version
- name: Build docker image
- uses: whoan/docker-build-with-cache-action@v5
with:
username: vaihtovirta
password: "${{ secrets.GITHUB_TOKEN }}"
registry: docker.pkg.github.com
image_name: timecodes-api_base
push_image_and_stages: false
pull_image_and_stages: false
- name: Build docker image for tests
run: |
cp .env.example .env
docker-compose build app_test
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u vaihtovirta --password-stdin
docker-compose build --pull app_test
- name: Run tests
run: docker-compose run app_test go test ./... -covermode=count -coverprofile=coverage.out
run: docker-compose run --rm app_test go test ./... -covermode=count -coverprofile=tmp/coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1.0.2
with:
infile: coverage.out
infile: tmp/coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Build and push base image
on:
push:
branches:
- master
jobs:
push_image:
runs-on: ubuntu-latest
steps:
- name: Checkout current branch
uses: actions/checkout@master
- name: Build base docker image
run: |
cp .env.example .env
docker login docker.pkg.github.com -u vaihtovirta -p ${{ secrets.GITHUB_TOKEN }}
docker-compose build --pull app_base
- name: Push docker image to Github registry
run: |
docker push docker.pkg.github.com/letscode-io/timecodes-api/timecodes-api_base:latest
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:alpine AS builder
FROM docker.pkg.github.com/letscode-io/timecodes-api/timecodes-api_base:latest AS base

ENV APP_HOME=/usr/src/app

Expand All @@ -25,12 +25,8 @@ FROM alpine AS final

ENV APP_HOME=/usr/src/app

RUN apk update --purge \
&& apk upgrade --purge \
&& rm -rf /var/cache/apk/*

WORKDIR $APP_HOME

COPY --from=builder $APP_HOME/application $APP_HOME/
COPY --from=base $APP_HOME/application $APP_HOME/

ENTRYPOINT ["./application"]
18 changes: 18 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:alpine

ENV APP_HOME=/usr/src/app

RUN apk update \
&& apk upgrade \
&& apk add --upgrade git \
&& rm -rf /var/cache/apk/*

RUN mkdir -p $APP_HOME

WORKDIR $APP_HOME

COPY go.mod go.sum $APP_HOME/

RUN go mod download

COPY . $APP_HOME
11 changes: 7 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
version: "3.5"

services:
app_base:
image: docker.pkg.github.com/letscode-io/timecodes-api/timecodes-api_base:latest
build:
context: .
dockerfile: Dockerfile.base
app_test:
build:
context: .
dockerfile: Dockerfile
target: builder
target: base
depends_on:
- db
environment:
- CGO_ENABLED=0
env_file:
- .env.test
ports:
- "8080:8080"
volumes:
- .:/usr/src/app
- ./tmp:/usr/src/app/tmp
app_dev:
build:
context: .
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/jinzhu/gorm v1.9.12
github.com/khaiql/dbcleaner v2.3.0+incompatible
github.com/rs/cors v1.7.0
github.com/stretchr/testify v1.6.0
github.com/stretchr/testify v1.6.1
google.golang.org/api v0.25.0
gopkg.in/khaiql/dbcleaner.v2 v2.3.0
)
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho=
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down Expand Up @@ -280,10 +278,10 @@ google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsb
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.24.0 h1:cG03eaksBzhfSIk7JRGctfp3lanklcOM/mTGvow7BbQ=
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.25.0 h1:LodzhlzZEUfhXzNUMIfVlf9Gr6Ua5MMtoFWh7+f47qA=
google.golang.org/api v0.25.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.26.0 h1:VJZ8h6E8ip82FRpQl848c5vAadxlTXrUh8RzQzSRm08=
google.golang.org/api v0.26.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down