-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
46 lines (34 loc) · 1.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM node:16 AS nodebuilder
WORKDIR /app
COPY web .
RUN yarn && yarn build
FROM golang AS gobuilder
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libjpeg-dev libpng-dev libgif-dev libwebp-dev \
libfontconfig1-dev libfreetype6-dev libgomp1 libexpat1-dev
ENV IMAGEMAGICK_VERSION=7.1.0-47
RUN wget -q https://github.com/ImageMagick/ImageMagick/archive/${IMAGEMAGICK_VERSION}.tar.gz \
&& tar xf ${IMAGEMAGICK_VERSION}.tar.gz \
&& cd ImageMagick-${IMAGEMAGICK_VERSION} \
&& ./configure --enable-shared=no --with-zip=no && make && make install \
&& ldconfig /usr/local/lib
WORKDIR /app
COPY . .
COPY --from=nodebuilder /app/dist /app/web/dist
RUN export CGO_CFLAGS_ALLOW="-fopenmp" && \
export CGO_CFLAGS="`pkg-config --cflags MagickWand MagickCore`" && \
export CGO_LDFLAGS="`pkg-config --libs MagickWand MagickCore` \
-ljpeg -lpng -lwebp -lwebpmux -lwebpdemux \
-lbrotlienc -lbrotlidec -lbrotlicommon \
-lfontconfig -lfreetype -lgomp -lexpat -luuid -lz -lm -ldl" && \
go env -w GOPROXY=https://goproxy.cn,direct && \
go build -tags no_pkgconfig gopkg.in/gographics/imagick.v3/imagick && \
export KIMG_TAG="`git describe "--abbrev=0" "--tags"`" && \
go build -tags netgo -ldflags "-linkmode 'external' -extldflags '-static' -w -s -X 'main.KimgVersion=${KIMG_TAG}'" -o kimg main/kimg.go
FROM scratch
COPY --from=gobuilder /app/kimg .
COPY --from=gobuilder /app/kimg.yaml .
COPY --from=gobuilder /app/fonts/arial.ttf .
COPY --from=gobuilder /app/LICENSE .
EXPOSE 80
ENTRYPOINT ["/kimg"]