#10 support docker build image for production.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
d12a27c9d9
commit
2bf88e4a4f
|
@ -25,8 +25,10 @@ _testmain.go
|
||||||
|
|
||||||
gin-bin
|
gin-bin
|
||||||
key.pem
|
key.pem
|
||||||
config.yaml
|
config.yml
|
||||||
bin/*
|
bin/*
|
||||||
.DS_Store
|
.DS_Store
|
||||||
coverage.out
|
coverage.out
|
||||||
gopush/log/*.log
|
gopush/log/*.log
|
||||||
|
build.tar.gz
|
||||||
|
gopush.tar.gz
|
||||||
|
|
10
Makefile
10
Makefile
|
@ -5,6 +5,7 @@ VERSION=0.0.1
|
||||||
DEPS := $(wildcard *.go)
|
DEPS := $(wildcard *.go)
|
||||||
BUILD_IMAGE := "appleboy/gopush-build:latest"
|
BUILD_IMAGE := "appleboy/gopush-build:latest"
|
||||||
TEST_IMAGE := "appleboy/gopush-testing:latest"
|
TEST_IMAGE := "appleboy/gopush-testing:latest"
|
||||||
|
PRODUCTION_IMAGE := "appleboy/gopush"
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
|
@ -15,15 +16,14 @@ test:
|
||||||
cd gopush && go test -v -covermode=count -coverprofile=coverage.out
|
cd gopush && go test -v -covermode=count -coverprofile=coverage.out
|
||||||
|
|
||||||
docker_build: clean
|
docker_build: clean
|
||||||
tar -zcvf build.tar.gz gopush.go gopush script
|
tar -zcvf build.tar.gz gopush.go gopush
|
||||||
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build .
|
docker build --rm -t $(BUILD_IMAGE) -f docker/Dockerfile.build .
|
||||||
docker run --rm $(BUILD_IMAGE) > bin.tar.gz
|
docker run --rm $(BUILD_IMAGE) > gopush.tar.gz
|
||||||
tar -zxvf bin.tar.gz
|
docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist .
|
||||||
-rm -rf bin.tar.gz build.tar.gz
|
|
||||||
|
|
||||||
docker_test:
|
docker_test:
|
||||||
@docker build --rm -t $(TEST_IMAGE) -f docker/Dockerfile.testing .
|
@docker build --rm -t $(TEST_IMAGE) -f docker/Dockerfile.testing .
|
||||||
@docker run --rm -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "cd gopush && go test -v"
|
@docker run --rm -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "cd gopush && go test -v"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build.tar.gz bin.tar.gz bin/*
|
-rm -rf build.tar.gz gopush.tar.gz bin/*
|
||||||
|
|
|
@ -11,8 +11,8 @@ api:
|
||||||
stat_go_uri: "/api/status"
|
stat_go_uri: "/api/status"
|
||||||
|
|
||||||
android:
|
android:
|
||||||
enabled: false
|
enabled: true
|
||||||
apikey: ""
|
apikey: "YOUR_API_KEY"
|
||||||
|
|
||||||
ios:
|
ios:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
FROM golang:1.6
|
FROM golang:1.6-alpine
|
||||||
|
|
||||||
MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>
|
MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>
|
||||||
|
|
||||||
|
RUN apk --update add git
|
||||||
RUN mkdir -p /tmp/build
|
RUN mkdir -p /tmp/build
|
||||||
Add build.tar.gz /tmp/build/
|
Add build.tar.gz /tmp/build/
|
||||||
WORKDIR /tmp/build
|
WORKDIR /tmp/build
|
||||||
RUN go get -v -d
|
RUN go get -v -d
|
||||||
RUN sh script/build.sh
|
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w" -o bin/gopush gopush.go
|
||||||
|
|
||||||
CMD tar -czf - bin
|
CMD tar -C bin -czf - gopush
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
FROM alpine
|
||||||
|
|
||||||
|
MAINTAINER Bo-Yi Wu <appleboy.tw@gmail.com>
|
||||||
|
|
||||||
|
RUN apk update && apk upgrade \
|
||||||
|
&& apk add ca-certificates \
|
||||||
|
&& rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
ADD gopush.tar.gz /app/
|
||||||
|
WORKDIR /app
|
||||||
|
ENTRYPOINT ["./gopush", "-c", "config/config.yml"]
|
||||||
|
EXPOSE 8088
|
Loading…
Reference in New Issue