diff --git a/Dockerfile b/Dockerfile index 5ff8cf67..0e73bde7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,29 @@ -# Development +# Install development environment FROM golang:1.12.2-alpine as builder -RUN apk add --no-cache git nodejs npm make gcc libc-dev -RUN npm i -g typescript -RUN git clone --depth=1 https://github.com/animenotifier/database ~/.aero/db/arn ENV GO111MODULE=on -RUN go install github.com/aerogo/pack && \ +RUN apk add --no-cache git nodejs npm make gcc libc-dev && \ + npm i -g typescript && \ + go install github.com/aerogo/pack && \ go install github.com/aerogo/run && \ - go install golang.org/x/tools/cmd/goimports -RUN mkdir /notify.moe -ADD go.mod go.sum /notify.moe/ + 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/ WORKDIR /notify.moe RUN go mod download -ADD . /notify.moe -RUN tsc && \ - pack && \ + +# 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 && \ GOOS=linux go build # Production