From a89f763629acf269c92fa2dadf2c4d21858f3c97 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Wed, 13 Nov 2019 19:12:33 -0800 Subject: [PATCH] Add Dockerfile --- .gitignore | 3 ++- Dockerfile | 13 +++++++++++ Makefile | 26 +++++++++++++++++++++ docker-compose.yml | 56 ---------------------------------------------- 4 files changed, 41 insertions(+), 57 deletions(-) create mode 100644 Dockerfile delete mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index def6daa..b6f8f39 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ node_modules/ dist/ venv/ -.DS_Store \ No newline at end of file +.DS_Store +podsync diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..70f9554 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM golang:1.12 as build +WORKDIR /work +COPY . . +RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 make build + +FROM alpine:3.10 +RUN apk --no-cache add \ + ca-certificates \ + youtube-dl \ + ffmpeg +WORKDIR /app/ +COPY --from=build /work/podsync /app/podsync +ENTRYPOINT ["/app/podsync"] diff --git a/Makefile b/Makefile index 965b200..1ef35f6 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,40 @@ BINPATH := $(abspath ./bin) GOLANGCI := $(BINPATH)/golangci-lint +.PHONY: all +all: build lint test + +# +# Build Podsync CLI binary +# +.PHONY: build +build: + go build -o podsync ./cmd/podsync + +# +# Build Docker image +# +.PHONY: docker +docker: + docker build -t mxpv/podsync . + +# +# Pull GolangCI-Lint dependency +# $(GOLANGCI): curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(BINPATH) v1.17.1 $(GOLANGCI) --version +# +# Run linter +# .PHONY: lint lint: $(GOLANGCI) $(GOLANGCI) run +# +# Run unit tests +# .PHONY: test test: go test ./... diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index ebcec49..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,56 +0,0 @@ -version: '2.2' - -services: - api: - image: mxpv/podsync_api - container_name: api - restart: always - ports: - - 5001 - environment: - - REDIS_CONNECTION_URL=redis://redis - - POSTGRES_CONNECTION_URL={POSTGRES_CONNECTION_URL} - - UPDATER_URL=http://updater:8080/update - - YOUTUBE_API_KEY={YOUTUBE_API_KEY} - - VIMEO_API_KEY={VIMEO_API_KEY} - - PATREON_CLIENT_ID={PATREON_CLIENT_ID} - - PATREON_SECRET={PATREON_SECRET} - - PATREON_REDIRECT_URL=https://podsync.net/user/patreon - - PATREON_WEBHOOKS_SECRET={PATREON_WEBHOOKS_SECRET} - - COOKIE_SECRET={COOKIE_SECRET} - - GIN_MODE=release - - AWS_REGION=us-east-1 - - DYNAMO_FEEDS_TABLE_NAME=Prod_Feeds - - DYNAMO_PLEDGES_TABLE_NAME=Prod_Pledges - - UPDATER_SQS_QUEUE_URL={URL} - redis: - image: redis:5.0.3 - container_name: redis - command: redis-server --appendonly yes --save 900 1 --save 300 10 --save 60 10000 - restart: always - volumes: - - /data/redis:/data - sysctls: - net.core.somaxconn: 1024 - nginx: - image: mxpv/nginx:latest - container_name: nginx - restart: always - ports: - - 80:80 - resolver: - image: mxpv/podsync_lambda:latest - container_name: resolver - restart: always - ports: - - 5002 - environment: - - AWS_REGION=us-east-1 - updater: - image: mxpv/updater:latest - restart: always - scale: 8 - environment: - - AWS_DEFAULT_REGION=us-east-1 - - UPDATER_SQS_QUEUE_URL={URL} - - DYNAMO_FEEDS_TABLE_NAME=Prod_Feeds