Skip to content

Commit

Permalink
KamimaiのDockerBuild追加 (#22)
Browse files Browse the repository at this point in the history
* Moved the mysql environment required for standalone operation to docker-compose.

* DockerFileの追加

* add docker ignore
  • Loading branch information
marnie-eure authored Sep 7, 2020
1 parent 86e9fa1 commit c51ecc1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.git
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM mysql:8.0.20
FROM golang:1.14.0-buster as builder
WORKDIR /go
COPY ./ .
RUN export GOPATH= && go mod download && go build -o /go/ -v -ldflags '-s -w' ./cmd/kamimai

ENV MYSQL_USER kamimai
ENV MYSQL_PASSWORD kamimai
ENV MYSQL_DATABASE kamimai
ENV MYSQL_ROOT_PASSWORD root
ENV MYSQL_HOST 127.0.0.1
ENV MYSQL_PORT 3306
FROM gcr.io/distroless/base
COPY --from=builder go/kamimai .
ENTRYPOINT ["/kamimai"]
CMD ["--help"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ build: gox
@mkdir -p $(ARTIFACTS_DIR)/$(VERSION) && cd $(ARTIFACTS_DIR)/$(VERSION); \
gox $(LDFLAGS) $(TARGETS)

build-docker-image:
docker build -t kamimai:$(VERSION) --no-cache --rm --compress .

release: ghr verify-github-token build
@ghr -c $(COMMITISH) -u $(PROJECT_USERNAME) -r $(PROJECT_REPONAME) -t $$GITHUB_TOKEN \
--replace $(VERSION) $(ARTIFACTS_DIR)/$(VERSION)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ func main() {
### Setup
```sh
docker build -t $ImageName .
docker run --name $ContainerName -d -it --rm -p 3306:3306 $ImageName
docker-compose up -d

# kamimai の実行
MYSQL_HOST=127.0.0.1 MYSQL_USER=kamimai MYSQL_PASSWORD=kamimai go run ./cmd/kamimai --dry-run --env=development --path=./examples/mysql create test
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '2'
services:
mysql:
image: mysql:8.0.20
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_USER: kamimai
MYSQL_PASSWORD: kamimai
MYSQL_DATABASE: kamimai
MYSQL_ROOT_PASSWORD: root
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
ports:
- "3306:3306"

0 comments on commit c51ecc1

Please sign in to comment.