toy/Dockerfile

56 lines
812 B
Docker
Raw Normal View History

2024-07-02 20:50:33 +00:00
FROM ruby:alpine AS base
2024-07-02 20:22:32 +00:00
WORKDIR /app
RUN <<EOT
gem update --system --no-document
gem install -N bundler
apk update
apk upgrade --no-cache
EOT
2024-07-02 21:45:24 +00:00
RUN mkdir -p /run/app
2024-07-02 20:22:32 +00:00
FROM base AS build
RUN <<EOT
apk add gcc musl-dev ruby-dev make
EOT
COPY Gemfile* .
RUN <<EOT
bundle config set --local without development
bundle install
EOT
2024-07-02 20:50:33 +00:00
FROM build AS dev
2024-07-02 20:22:32 +00:00
WORKDIR /app
RUN <<EOT
bundle install
EOT
CMD [ "sleep", "infinity" ]
FROM base
# RUN useradd ruby --home /app --shell /bin/sh
RUN adduser ruby -h /app -D
2024-07-02 21:45:24 +00:00
RUN mkdir -p /run/app
RUN chown ruby:ruby /run/app
2024-07-02 20:22:32 +00:00
USER ruby:ruby
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build --chown=ruby:ruby /app /app
COPY --chown=ruby:ruby . .
EXPOSE 4567
CMD [ "bundle", "exec", "rackup", "--host", "0.0.0.0", "--port", "4567" ]