Goreleaser (#241)

* add goreleaser tooling

* add files + hook

* update hooks

* allow passing build-dir using cli args

* build tweaks

* tweak more

* update drone and goreleaser

* chill out tests

* remove postgres

* docker push on snapshot

* update releaser
This commit is contained in:
tobi 2021-09-24 13:14:20 +02:00 committed by GitHub
commit d515c9f1ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 253 additions and 136 deletions

View file

@ -1,44 +1,4 @@
# STEP ONE: build the GoToSocial binary
FROM golang:1.17.1-alpine3.14 AS binary_builder
RUN apk update && apk upgrade --no-cache
RUN apk add git
# create build dir
RUN mkdir -p /go/src/github.com/superseriousbusiness/gotosocial
WORKDIR /go/src/github.com/superseriousbusiness/gotosocial
# move source files
ADD cmd /go/src/github.com/superseriousbusiness/gotosocial/cmd
ADD internal /go/src/github.com/superseriousbusiness/gotosocial/internal
ADD testrig /go/src/github.com/superseriousbusiness/gotosocial/testrig
ADD docs/swagger.go /go/src/github.com/superseriousbusiness/gotosocial/docs/swagger.go
# dependencies and vendor
ADD go.mod /go/src/github.com/superseriousbusiness/gotosocial/go.mod
ADD go.sum /go/src/github.com/superseriousbusiness/gotosocial/go.sum
ADD vendor /go/src/github.com/superseriousbusiness/gotosocial/vendor
# move .git dir and version for versioning
ADD .git /go/src/github.com/superseriousbusiness/gotosocial/.git
ADD version /go/src/github.com/superseriousbusiness/gotosocial/version
# move the build script
ADD scripts/build.sh /go/src/github.com/superseriousbusiness/gotosocial/build.sh
# do the build step
RUN ./build.sh
# STEP TWO: build the web assets
FROM node:16.9.0-alpine3.14 AS web_builder
RUN apk update && apk upgrade --no-cache
COPY web /web
WORKDIR /web/gotosocial-styling
RUN yarn install
RUN BUILD_DIR=../assets node index.js
# STEP THREE: bundle the admin webapp
# bundle the admin webapp
FROM node:16.9.0-alpine3.14 AS admin_builder
RUN apk update && apk upgrade --no-cache
RUN apk add git
@ -49,19 +9,15 @@ WORKDIR /gotosocial-admin
RUN npm install
RUN node index.js
# STEP FOUR: build the final container
FROM alpine:3.14.2 AS executor
RUN apk update && apk upgrade --no-cache
# copy over the binary from the first stage
RUN mkdir -p /gotosocial/storage
COPY --from=binary_builder /go/src/github.com/superseriousbusiness/gotosocial/gotosocial /gotosocial/gotosocial
COPY gotosocial /gotosocial/gotosocial
# copy over the web directory with templates etc
COPY --from=web_builder web /gotosocial/web
# put the swagger yaml in the web assets directory so it can be accessed
COPY docs/api/swagger.yaml /gotosocial/web/assets/swagger.yaml
COPY web /gotosocial/web
# copy over the admin directory
COPY --from=admin_builder /gotosocial-admin/public /gotosocial/web/assets/admin