Skip to content

Commit

Permalink
Merge pull request golang-migrate#24 from Its-Alex/master
Browse files Browse the repository at this point in the history
Dockerization
  • Loading branch information
dhui authored May 9, 2018
2 parents 81e9fff + fb7bb4f commit a0b03c3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Project
FAQ.md
README.md
LICENSE
Makefile
.gitignore
.travis.yml
CONTRIBUTING.md
MIGRATIONS.md
docker-deploy.sh

# Golang
testing
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ deploy:
go: "1.10"
repo: golang-migrate/migrate
tags: true
- provider: script
script: ./docker-deploy.sh
on:
go: "1.10"
repo: golang-migrate/migrate
tags: true
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.10-alpine3.7 AS downloader

RUN apk add --no-cache git gcc musl-dev

WORKDIR /go/src/github.com/golang-migrate/migrate

COPY *.go ./
COPY cli ./cli
COPY database ./database
COPY source ./source

RUN go get -v ./... && \
go get -u github.com/fsouza/fake-gcs-server/fakestorage && \
go get -u github.com/kshvakov/clickhouse && \
GOOS=linux GOARCH=386 go build -a -o build/migrate.linux-386 -ldflags='-X main.Version=$(VERSION)' -tags '$(DATABASE) $(SOURCE)' ./cli

FROM alpine:3.7

RUN apk add --no-cache ca-certificates

COPY --from=downloader /go/src/github.com/golang-migrate/migrate/build/migrate.linux-386 /migrate
RUN chmod u+x /migrate

ENTRYPOINT ["/migrate"]
CMD ["--help"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ $ brew install migrate --with-postgres
$ migrate -database postgres://localhost:5432/database up 2
```

### Docker usage

```
$ docker run -v {{ migration dir }}:/migrations --network host migrate/migrate
-path=/migrations/ -database postgres://localhost:5432/database up 2
```

## Use in your Go project

Expand Down
5 changes: 5 additions & 0 deletions docker-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && \
docker build . -t migrate/migrate:"$TRAVIS_TAG" && \
docker push migrate/migrate:"$TRAVIS_TAG"

0 comments on commit a0b03c3

Please sign in to comment.