From a2712f7b923e3e05d0f46e54fbcacef3380aca31 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Tue, 21 Jul 2020 19:37:23 +0900 Subject: [PATCH] ci: Add docker-compose.yml (#406) --- .github/workflows/dev-image.yml | 10 +++++---- Makefile | 38 ++++++--------------------------- docker-compose.yml | 16 ++++++++++++++ 3 files changed, 29 insertions(+), 35 deletions(-) create mode 100644 docker-compose.yml diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml index 857813832..92d617672 100644 --- a/.github/workflows/dev-image.yml +++ b/.github/workflows/dev-image.yml @@ -10,6 +10,7 @@ on: - '.nvmrc' - 'Dockerfile' - 'Makefile' + - 'docker-compose.yml' pull_request: types: - opened @@ -20,6 +21,7 @@ on: - '.nvmrc' - 'Dockerfile' - 'Makefile' + - 'docker-compose.yml' jobs: skipci: @@ -34,10 +36,10 @@ jobs: - uses: actions/checkout@v2.3.1 - name: Login to Packages run: echo '${{ secrets.GITHUB_TOKEN }}' | docker login 'docker.pkg.github.com' -u 'peaceiris' --password-stdin - - run: make pull + - run: docker-compose pull --quiet if: github.event_name == 'pull_request' - run: make build - - run: make cirun cmd="npm ci" - - run: make ciall - - run: make push + - run: make ci + - run: make all + - run: docker-compose push if: github.ref == 'refs/heads/main' diff --git a/Makefile b/Makefile index 7af7624bf..bb96f2c3f 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,22 @@ -cmd := "bash" -msg := "" IMAGE_NAME := docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest NODE_VERSION := $(shell cat ./.nvmrc) -DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/root/.gitconfig $(IMAGE_NAME) -DOCKER_RUN_CI := docker run --rm -v ${PWD}:/repo $(IMAGE_NAME) - .PHONY: build build: - docker build . \ - --build-arg NODE_VERSION=$(NODE_VERSION) \ - --cache-from=${IMAGE_NAME} \ - -t $(IMAGE_NAME) - -.PHONY: pull -pull: - docker pull ${IMAGE_NAME} - -.PHONY: push -push: - docker push ${IMAGE_NAME} + docker-compose build --build-arg NODE_VERSION=$(NODE_VERSION) .PHONY: run run: - $(DOCKER_RUN) $(cmd) + docker-compose run --rm dev bash -.PHONY: cirun -cirun: - $(DOCKER_RUN_CI) $(cmd) +.PHONY: ci +ci: + docker-compose run --rm -T dev npm ci .PHONY: test test: - $(DOCKER_RUN) npm test - -.PHONY: commit -commit: - $(DOCKER_RUN) git commit -m "$(msg)" + docker-compose run --rm -T dev npm test .PHONY: all all: - $(DOCKER_RUN) npm run all - -.PHONY: ciall -ciall: - $(DOCKER_RUN_CI) npm run all + docker-compose run --rm -T dev npm run all diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..2490d72c7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.2' + +services: + dev: + image: 'docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest' + build: + context: . + cache_from: + - 'docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest' + container_name: peaceiris_actions_github_pages + volumes: + - ${PWD}:/repo + stdin_open: true + tty: true + command: + - bash