diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1d1fe94 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +Dockerfile \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ed8df90..98ece58 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -22,7 +22,22 @@ jobs: - name: Test run: go test -v -tags skip ./... - + - name: Build and push Docker images + if: success() + uses: docker/build-push-action@v2.3.0 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: gogems/jet:latest + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} coverage: runs-on: ubuntu-latest steps: @@ -43,4 +58,4 @@ jobs: uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: coverage.lcov \ No newline at end of file + path-to-lcov: coverage.lcov diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a9e52d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM golang:1.16-alpine as BUILD +RUN apk --update upgrade \ + && apk --no-cache --no-progress add git bash gcc curl tar ca-certificates \ + && update-ca-certificates \ + && rm -rf /var/cache/apk/* +WORKDIR /go/src/github.com/go-gems/jet + +COPY go.mod . +COPY go.sum . +RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download + +COPY . /go/src/github.com/go-gems/jet +RUN go build -o jet . + +FROM alpine as RUN +COPY --from=BUILD /go/src/github.com/go-gems/jet/jet /usr/local/bin/jet +RUN chmod 777 /usr/local/bin/jet +EXPOSE 8000 +ENTRYPOINT ["jet"] + +