rss2twitter/Dockerfile

56 lines
1.7 KiB
Text
Raw Normal View History

2018-12-05 06:40:31 +01:00
FROM umputun/baseimage:buildgo-latest as build
ARG COVERALLS_TOKEN
ARG CI
ARG TRAVIS
ARG TRAVIS_BRANCH
ARG TRAVIS_COMMIT
ARG TRAVIS_JOB_ID
ARG TRAVIS_JOB_NUMBER
ARG TRAVIS_OS_NAME
ARG TRAVIS_PULL_REQUEST
ARG TRAVIS_PULL_REQUEST_SHA
ARG TRAVIS_REPO_SLUG
ARG TRAVIS_TAG
2018-12-05 17:54:56 +01:00
ARG TRAVIS_BUILD_NUMBER
2018-12-05 06:40:31 +01:00
WORKDIR /go/src/github.com/umputun/rss2twitter
ADD . /go/src/github.com/umputun/rss2twitter
# run tests
RUN cd app && go test ./...
# linters
2018-12-05 17:29:31 +01:00
RUN golangci-lint run --out-format=tab --disable-all --tests=false --enable=interfacer --enable=unconvert --enable=megacheck \
--enable=structcheck --enable=gas --enable=gocyclo --enable=dupl --enable=misspell --enable=maligned --enable=unparam \
--enable=varcheck --enable=deadcode --enable=typecheck --enable=errcheck ./...
2018-12-05 06:40:31 +01:00
# coverage report
RUN mkdir -p target && /script/coverage.sh
# submit coverage to coverals if COVERALLS_TOKEN in env
RUN if [ -z "$COVERALLS_TOKEN" ] ; then \
echo "coverall not enabled" ; \
2018-12-05 18:06:57 +01:00
else goveralls -coverprofile=.cover/cover.out -service=travis-ci -repotoken $COVERALLS_TOKEN || echo "coverall failed!"; fi && \
2018-12-05 18:05:23 +01:00
cat .cover/cover.out
2018-12-05 06:40:31 +01:00
RUN \
2018-12-05 17:47:55 +01:00
if [ -z "$TRAVIS" ] ; then \
echo "runs outside of travis" && version=$(/script/git-rev.sh); \
else version=${TRAVIS_BRANCH}-${TRAVIS_BUILD_NUMBER}-${TRAVIS_COMMIT:0:7}-$(date +%Y%m%dT%H:%M:%S); fi && \
2018-12-05 06:40:31 +01:00
echo "version=$version" && \
go build -o rss2twitter -ldflags "-X main.revision=${version} -s -w" ./app
FROM umputun/baseimage:app-latest
COPY --from=build /go/src/github.com/umputun/rss2twitter/rss2twitter /srv/rss2twitter
2018-12-05 08:49:59 +01:00
RUN \
chown -R app:app /srv && \
chmod +x /srv/rss2twitter
2018-12-05 06:40:31 +01:00
WORKDIR /srv
CMD ["/srv/rss2twitter"]
ENTRYPOINT ["/init.sh"]