Dockerfile: use multistage build to avoid shipping build tools

This commit is contained in:
RyanSquared 2023-04-30 06:16:30 -04:00
parent a3c94eef9f
commit 0bd9c512c2
Signed by untrusted user who does not match committer: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 7 additions and 2 deletions

View File

@ -1,12 +1,17 @@
FROM jekyll/minimal:3.8 FROM ruby:3.2.2-alpine AS builder
RUN apk update && apk add g++ make RUN apk update && apk add g++ make
RUN mkdir -p /home RUN mkdir -p /home
COPY Gemfile /home COPY Gemfile /home
COPY Gemfile.lock /home COPY Gemfile.lock /home
RUN chmod -R 777 /home
WORKDIR /home WORKDIR /home
RUN bundle install RUN bundle install
FROM ruby:3.2.2-alpine
COPY --from=builder /usr/local/bundle /usr/local/bundle
RUN mkdir -p /home
WORKDIR /home
CMD ["jekyll", "serve"] CMD ["jekyll", "serve"]