From 43092bb64480cc0a258bec23071254bc5bd05ee2 Mon Sep 17 00:00:00 2001 From: Umputun Date: Sun, 8 Jul 2018 18:43:58 -0500 Subject: [PATCH] skip build steps with ARG and compose #143 (#144) --- Dockerfile | 28 +++++++++----- README.md | 4 +- compose-dev.yml => compose-dev-backend.yml | 8 +++- compose-dev-frontend.yml | 43 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) rename compose-dev.yml => compose-dev-backend.yml (87%) create mode 100644 compose-dev-frontend.yml diff --git a/Dockerfile b/Dockerfile index 88f20e60..44a6b078 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,27 +12,33 @@ ARG TRAVIS_PULL_REQUEST ARG TRAVIS_PULL_REQUEST_SHA ARG TRAVIS_REPO_SLUG ARG TRAVIS_TAG - ARG DRONE ARG DRONE_TAG ARG DRONE_COMMIT ARG DRONE_BRANCH ARG DRONE_PULL_REQUEST +ARG SKIP_BACKEND_TEST + WORKDIR /go/src/github.com/umputun/remark/backend ADD backend /go/src/github.com/umputun/remark/backend -RUN cd app && go test ./... +RUN cd app && \ + if [ -z "$SKIP_BACKEND_TEST" ] ; then go test ./... ; \ + else echo "skip backend test" ; fi -RUN gometalinter --disable-all --deadline=300s --vendor --enable=vet --enable=vetshadow --enable=golint \ +RUN if [ -z "$SKIP_BACKEND_TEST" ] ; then \ + gometalinter --disable-all --deadline=300s --vendor --enable=vet --enable=vetshadow --enable=golint \ --enable=staticcheck --enable=ineffassign --enable=goconst --enable=errcheck --enable=unconvert \ - --enable=deadcode --enable=gosimple --enable=gas --exclude=test --exclude=mock --exclude=vendor ./... + --enable=deadcode --enable=gosimple --enable=gas --exclude=test --exclude=mock --exclude=vendor ./... ; \ + else echo "skip backend linters" ; fi # coverage test, submit to coverals if COVERALLS_TOKEN in env -RUN mkdir -p target && /script/coverage.sh RUN if [ -z "$COVERALLS_TOKEN" ] ; then \ echo coverall not enabled ; \ - else goveralls -coverprofile=.cover/cover.out -service=travis-ci -repotoken $COVERALLS_TOKEN || echo "coverall failed!"; fi + else \ + mkdir -p target && /script/coverage.sh && \ + goveralls -coverprofile=.cover/cover.out -service=travis-ci -repotoken $COVERALLS_TOKEN || echo "coverall failed!"; fi # get revision from git. if DRONE presented use DRONE_* git env to make version RUN \ @@ -45,12 +51,16 @@ RUN \ FROM node:9.4-alpine as build-frontend +ARG CI +ARG SKIP_FRONTEND_TEST + ADD web /srv/web RUN apk add --no-cache --update git RUN \ - cd /srv/web && \ - npm i && npm run lint && npm run test && npm run build && \ - rm -rf ./node_modules + cd /srv/web && npm i && \ + if [ -z "$SKIP_FRONTEND_TEST" ] ; then npm run lint && npm run test ; \ + else echo "skip frontend tests and lint" ; fi && \ + npm run build && rm -rf ./node_modules FROM umputun/baseimage:app-latest diff --git a/README.md b/README.md index d7d87332..a56efaec 100644 --- a/README.md +++ b/README.md @@ -224,8 +224,8 @@ Also you can use fully functional local version to develop and test both fronten To bring it up run: ```bash -docker-compose -f compose-dev.yml build -docker-compose -f compose-dev.yml up +docker-compose -f compose-dev-frontend.yml build +docker-compose -f compose-dev-frontend.yml up ``` It starts Remark42 on `localhost:8080` diff --git a/compose-dev.yml b/compose-dev-backend.yml similarity index 87% rename from compose-dev.yml rename to compose-dev-backend.yml index 97be505f..c7ff67ea 100644 --- a/compose-dev.yml +++ b/compose-dev-backend.yml @@ -6,7 +6,12 @@ version: '2' services: remark42: - build: . + build: + context: . + dockerfile: Dockerfile + args: + - SKIP_FRONTEND_TEST=true + image: umputun/remark42:dev container_name: "remark42-dev" hostname: "remark42-dev" @@ -33,6 +38,5 @@ services: - ADMIN=dev_user # set admin flag for default user on local ouath2 volumes: - ./var:/srv/var - #- ./web:/srv/web # uncomment to map web directory directly. It will propagate local changes to container without redeploy command: /srv/start.sh diff --git a/compose-dev-frontend.yml b/compose-dev-frontend.yml new file mode 100644 index 00000000..f7e5f326 --- /dev/null +++ b/compose-dev-frontend.yml @@ -0,0 +1,43 @@ +# compose file for local development +# starts backend on 8080 with basic auth "dev:password" and Dev oauth2 provider on port 8084 +# UI on https://127.0.0.1:8080/web + +version: '2' + +services: + remark42: + build: + context: . + dockerfile: Dockerfile + args: + - SKIP_BACKEND_TEST=true + + image: umputun/remark42:dev + container_name: "remark42-dev" + hostname: "remark42-dev" + + logging: + driver: json-file + options: + max-size: "10m" + max-file: "5" + + ports: + - "8080:8080" # primary rest server + - "8084:8084" # local oauth2 server + + environment: + - USER # preset environment, UID on the host machine, i.e `id -u` + - REMARK_URL=http://127.0.0.1:8080 + - SECRET=12345 + - STORE_BOLT_PATH=/srv/var/db + - BACKUP_PATH=/srv/var/backup + - DEBUG=true + - DEV_PASSWD=password + - AUTH_DEV=true # activate local oauth "dev" + - ADMIN=dev_user # set admin flag for default user on local ouath2 + volumes: + - ./var:/srv/var + # - ./web/public:/srv/web # uncomment to allow direct deployment of web parts + + command: /srv/start.sh