answer/Dockerfile

46 lines
1.3 KiB
Docker
Raw Normal View History

2022-09-27 17:59:05 +08:00
FROM node:16 AS node-builder
LABEL maintainer="mingcheng<mc@sf.com>"
COPY . /answer
WORKDIR /answer
2022-09-29 12:37:02 +08:00
RUN make install-ui-packages ui && mv ui/build /tmp
2022-09-27 17:59:05 +08:00
FROM golang:1.18 AS golang-builder
LABEL maintainer="aichy"
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PACKAGE github.com/segmentfault/answer
ENV GOPROXY https://goproxy.cn,direct
ENV BUILD_DIR ${GOPATH}/src/${PACKAGE}
# Build
COPY . ${BUILD_DIR}
WORKDIR ${BUILD_DIR}
2022-09-29 12:37:02 +08:00
COPY --from=node-builder /tmp/build ${BUILD_DIR}/ui/build
2022-09-27 17:59:05 +08:00
RUN make clean build && \
cp answer /usr/bin/answer && \
2022-09-29 10:14:57 +08:00
mkdir -p /data/upfiles && chmod 777 /data/upfiles && \
mkdir -p /data/i18n && chmod 777 /data/i18n && cp -r i18n/*.yaml /data/i18n
2022-09-28 17:45:23 +08:00
2022-09-27 17:59:05 +08:00
FROM debian:bullseye
ENV TZ "Asia/Shanghai"
RUN sed -i 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \
&& sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apt -y update \
&& apt -y upgrade \
&& apt -y install ca-certificates openssl tzdata curl netcat dumb-init \
&& apt -y autoremove \
&& mkdir -p /tmp/cache
2022-09-27 17:59:05 +08:00
COPY --from=golang-builder /data /data
VOLUME /data
COPY --from=golang-builder /usr/bin/answer /usr/bin/answer
2022-09-28 17:33:48 +08:00
COPY /script/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
2022-09-27 17:59:05 +08:00
EXPOSE 80
2022-09-28 17:33:48 +08:00
ENTRYPOINT ["/entrypoint.sh"]