chore(docker): add dockerfile

add dockerfile

Signed-off-by: mritd <mritd@linux.com>
This commit is contained in:
mritd 2020-09-02 15:30:20 +08:00
parent bfd2340732
commit 47c25aab02
No known key found for this signature in database
GPG key ID: 98C41327E6D3E645

44
Dockerfile Normal file
View file

@ -0,0 +1,44 @@
FROM node:lts-alpine3.12 AS fe-builder
COPY ./assets /assets
WORKDIR /assets
RUN set -ex \
&& apk upgrade \
&& npm install -g yarn \
&& yarn install \
&& yarn run build
FROM golang:1.15.0-alpine3.12 AS be-builder
ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn
COPY . /go/src/github.com/HFO4/cloudreve
COPY --from=fe-builder /assets/build/ /go/src/github.com/HFO4/cloudreve/assets/build/
WORKDIR /go/src/github.com/HFO4/cloudreve
RUN set -ex \
&& apk upgrade \
&& apk add git \
&& export COMMIT_SHA=$(git rev-parse --short HEAD) \
&& export VERSION=$(git describe --tags) \
&& (cd && go get github.com/rakyll/statik) \
&& statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f \
&& go install -ldflags "-X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=${VERSION}'
-X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=${COMMIT_SHA}'\
-w -s"
FROM alpine:3.12 AS dist
LABEL maintainer="mritd <mritd@linux.com>"
RUN apk upgrade \
&& apk add tzdata \
&& rm -rf /var/cache/apk/*
COPY --from=be-builder /go/bin/cloudreve /usr/bin/cloudreve
ENTRYPOINT ["cloudreve"]