36 lines
1002 B
Docker
Raw Normal View History

2019-04-08 23:14:54 +00:00
# Install development environment
2019-04-08 10:16:59 +00:00
FROM golang:1.12.2-alpine as builder
2019-04-08 11:18:18 +00:00
ENV GO111MODULE=on
2019-04-08 23:14:54 +00:00
RUN apk add --no-cache git nodejs npm make gcc libc-dev && \
npm i -g typescript && \
go install github.com/aerogo/pack && \
2019-04-08 11:18:18 +00:00
go install github.com/aerogo/run && \
2019-04-08 23:14:54 +00:00
go install golang.org/x/tools/cmd/goimports && \
git clone --depth=1 https://github.com/animenotifier/database ~/.aero/db/arn && \
mkdir /notify.moe
# Download dependencies when go.mod or go.sum changes
COPY go.mod go.sum /notify.moe/
2019-04-08 05:43:13 +00:00
WORKDIR /notify.moe
RUN go mod download
2019-04-08 23:14:54 +00:00
# Run Typescript compiler when scripts change
COPY ./scripts /notify.moe/scripts
COPY ./tsconfig.json /notify.moe/
WORKDIR /notify.moe
RUN tsc
# Build
COPY . /notify.moe/
WORKDIR /notify.moe
RUN pack && \
2019-04-08 11:18:18 +00:00
GOOS=linux go build
2019-04-08 10:16:59 +00:00
2019-04-08 11:18:18 +00:00
# Production
2019-04-08 10:16:59 +00:00
FROM alpine:latest as production
2019-04-09 06:22:44 +00:00
RUN apk add --no-cache ca-certificates
2019-04-08 10:16:59 +00:00
COPY --from=builder /root/.aero /root/.aero
COPY --from=builder /notify.moe /notify.moe
2019-04-08 11:18:18 +00:00
ENV ARN_ROOT=/notify.moe
2019-04-08 10:16:59 +00:00
WORKDIR /notify.moe
CMD ["./notify.moe"]