diff --git a/.drone.yml b/.drone.yml index a216589..fc2a990 100644 --- a/.drone.yml +++ b/.drone.yml @@ -4,24 +4,36 @@ name: default concurrency: limit: 1 steps: - - name: build and upload - image: golang:1.14.0-alpine3.11 + - name: build + image: xsteadfastx/blog + pull: always + environment: + WEBMENTIONIO_TOKEN: + from_secret: webmentionio_token + commands: + - curl "https://webmention.io/api/mentions?token=$$WEBMENTIONIO_TOKEN" -o data/mentions.json + - make build + when: + branch: + - master + + - name: upload + image: xsteadfastx/blog pull: always environment: FTP_PASS: from_secret: ftp_pass - WEBMENTIONIO_TOKEN: - from_secret: webmentionio_token commands: - - apk add --no-cache curl make git npm - - mkdir -p ~/.config/rclone - make rclone_config - - cat ~/.config/rclone/rclone.conf - - make install_deps - - curl "https://webmention.io/api/mentions?token=$$WEBMENTIONIO_TOKEN" -o data/mentions.json - - make build - make ftp_upload - - npm install @remy/webmention + when: + branch: + - master + + - name: mention + image: xsteadfastx/blog + pull: always + commands: - npx webmention https://xsteadfastx.org/ --limit 10 --send --debug when: branch: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..138c7c9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.14.0-alpine3.11 as builder + +ARG HUGO_VERSION=0.65.3 +ARG RCLONE_VERSION=1.51.0 + +RUN set -ex \ + && apk add --no-cache \ + gcc \ + git \ + musl-dev \ + && GO111MODULE=on GO_ENABLED=0 GOOS=linux go get -a -ldflags '-extldflags "-static"' -v github.com/gohugoio/hugo@v$HUGO_VERSION \ + && GO111MODULE=on GO_ENABLED=0 GOOS=linux go get -a -ldflags '-extldflags "-static"' -v github.com/rclone/rclone@v$RCLONE_VERSION + +FROM alpine:3.11 + +COPY --from=builder /go/bin/hugo /usr/bin/hugo +COPY --from=builder /go/bin/rclone /usr/bin/rclone + +RUN set -ex \ + && apk add --no-cache \ + curl \ + git \ + make \ + npm \ + && npm install @remy/webmention diff --git a/Makefile b/Makefile index efc1463..7544d44 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -HUGO_VERSION=0.65.3 -RCLONE_VERSION=1.51.0 OUTPUT_DIR=./public FTP_HOST=xsteadfastx.org FTP_USER=xstead_0 @@ -12,10 +10,11 @@ build: mkdir public/feed cp public/index.xml public/feed/index.html -install_deps: - apk add --no-cache git gcc musl-dev - GO111MODULE=on go get -v github.com/gohugoio/hugo@v$(HUGO_VERSION) - GO111MODULE=on go get -v github.com/rclone/rclone@v$(RCLONE_VERSION) +docker: + docker build -t quay.io/xsteadfastx/blog - < Dockerfile + +push: docker + docker push quay.io/xsteadfastx/blog ftp_upload: rclone sync -v --size-only $(OUTPUT_DIR) blog:/ @@ -33,4 +32,4 @@ slurp_mentions: sed -i 's/https:\/\/xsteadfastx.org/http:\/\/localhost:1313/g' data/mentions.json -.PHONY: clean build install_deps ftp_upload rclone_config slurp_mentions +.PHONY: clean build docker push install_deps ftp_upload rclone_config slurp_mentions