2021-07-27 14:45:27 +02:00
|
|
|
# STEP ONE: build the GoToSocial binary
|
2021-09-10 14:42:14 +02:00
|
|
|
FROM golang:1.17.1-alpine3.13 AS binary_builder
|
2021-06-28 12:17:20 +02:00
|
|
|
RUN apk update && apk upgrade --no-cache
|
|
|
|
RUN apk add git
|
2021-05-23 23:43:04 +02:00
|
|
|
|
|
|
|
# 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
|
2021-08-02 19:06:44 +02:00
|
|
|
ADD docs/swagger.go /go/src/github.com/superseriousbusiness/gotosocial/docs/swagger.go
|
2021-08-12 21:03:24 +02:00
|
|
|
|
|
|
|
# dependencies and vendor
|
2021-05-23 23:43:04 +02:00
|
|
|
ADD go.mod /go/src/github.com/superseriousbusiness/gotosocial/go.mod
|
|
|
|
ADD go.sum /go/src/github.com/superseriousbusiness/gotosocial/go.sum
|
2021-08-12 21:03:24 +02:00
|
|
|
ADD vendor /go/src/github.com/superseriousbusiness/gotosocial/vendor
|
2021-05-23 23:43:04 +02:00
|
|
|
|
2021-06-28 12:17:20 +02:00
|
|
|
# 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 build.sh /go/src/github.com/superseriousbusiness/gotosocial/build.sh
|
|
|
|
|
2021-05-23 23:43:04 +02:00
|
|
|
# do the build step
|
2021-06-28 12:17:20 +02:00
|
|
|
RUN ./build.sh
|
2021-05-23 23:43:04 +02:00
|
|
|
|
2021-07-27 14:45:27 +02:00
|
|
|
# STEP TWO: build the web assets
|
|
|
|
FROM node:16.5.0-alpine3.11 AS web_builder
|
|
|
|
RUN apk update && apk upgrade --no-cache
|
|
|
|
|
|
|
|
COPY web /web
|
|
|
|
WORKDIR /web/source
|
|
|
|
|
|
|
|
RUN yarn install
|
|
|
|
RUN node build.js
|
|
|
|
|
|
|
|
# STEP THREE: bundle the admin webapp
|
|
|
|
FROM node:16.5.0-alpine3.11 AS admin_builder
|
|
|
|
RUN apk update && apk upgrade --no-cache
|
|
|
|
RUN apk add git
|
|
|
|
|
|
|
|
RUN git clone https://github.com/superseriousbusiness/gotosocial-admin
|
|
|
|
WORKDIR /gotosocial-admin
|
|
|
|
|
|
|
|
RUN npm install
|
|
|
|
RUN node index.js
|
|
|
|
|
|
|
|
# STEP FOUR: build the final container
|
2021-05-23 23:43:04 +02:00
|
|
|
FROM alpine:3.13 AS executor
|
|
|
|
RUN apk update && apk upgrade --no-cache
|
|
|
|
|
|
|
|
# copy over the binary from the first stage
|
|
|
|
RUN mkdir -p /gotosocial/storage
|
2021-07-27 14:45:27 +02:00
|
|
|
COPY --from=binary_builder /go/src/github.com/superseriousbusiness/gotosocial/gotosocial /gotosocial/gotosocial
|
2021-05-23 23:43:04 +02:00
|
|
|
|
|
|
|
# copy over the web directory with templates etc
|
2021-07-27 14:45:27 +02:00
|
|
|
COPY --from=web_builder web /gotosocial/web
|
|
|
|
|
2021-08-02 19:06:44 +02:00
|
|
|
# put the swagger yaml in the web assets directory so it can be accessed
|
|
|
|
COPY docs/api/swagger.yaml /gotosocial/web/assets/swagger.yaml
|
|
|
|
|
2021-07-27 14:45:27 +02:00
|
|
|
# copy over the admin directory
|
|
|
|
COPY --from=admin_builder /gotosocial-admin/public /gotosocial/web/assets/admin
|
2021-05-23 23:43:04 +02:00
|
|
|
|
|
|
|
# make the gotosocial group and user
|
|
|
|
RUN addgroup -g 1000 gotosocial
|
|
|
|
RUN adduser -HD -u 1000 -G gotosocial gotosocial
|
|
|
|
|
|
|
|
# give ownership of the gotosocial dir to the new user
|
|
|
|
RUN chown -R gotosocial gotosocial /gotosocial
|
|
|
|
|
|
|
|
# become the user
|
|
|
|
USER gotosocial
|
|
|
|
|
|
|
|
WORKDIR /gotosocial
|
|
|
|
ENTRYPOINT [ "/gotosocial/gotosocial", "server", "start" ]
|