Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add docker-compose.yml #406

Merged
merged 1 commit into from
Jul 21, 2020
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
10 changes: 6 additions & 4 deletions .github/workflows/dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.nvmrc'
- 'Dockerfile'
- 'Makefile'
- 'docker-compose.yml'
pull_request:
types:
- opened
Expand All @@ -20,6 +21,7 @@ on:
- '.nvmrc'
- 'Dockerfile'
- 'Makefile'
- 'docker-compose.yml'

jobs:
skipci:
Expand All @@ -34,10 +36,10 @@ jobs:
- uses: actions/[email protected]
- 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'
38 changes: 7 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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