Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerfile 多阶段构建 #34

Merged
merged 1 commit into from
May 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
FROM archlinux

FROM archlinux as base
ARG MIRROR

WORKDIR /root/build
COPY . .

RUN if [[ $MIRROR ]]; then printf "Server = %s/\$repo/os/\$arch\n" $MIRROR > /etc/pacman.d/mirrorlist ; fi
RUN pacman -Syyu --noconfirm && \
pacman -S --needed --noconfirm git cmake make pkgconf clang spdlog openssl libconfig uriparser && \
cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .. && \
make -j install && \
pacman -Rsc --noconfirm git cmake make pkgconf clang && \
rm -rf /var/cache/pacman/pkg/* && \
rm -rf /root/build
RUN pacman -Syyu --noconfirm
RUN pacman -S --needed --noconfirm spdlog openssl libconfig uriparser

WORKDIR /root
FROM base as builder
WORKDIR root
COPY . .
RUN pacman -S --needed --noconfirm git cmake make pkgconf clang
RUN cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release .. && make -j install

FROM base as production
COPY --from=builder /usr/bin/candy /usr/bin/candy
ENTRYPOINT ["/usr/bin/candy"]
CMD ["-c", "/etc/candy.conf"]