Skip to content

Commit 6950d60

Browse files
committed
Make watchexec image with multiple phases
1 parent 88a24d2 commit 6950d60

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

features/watchexec-ruby-app/Dockerfile

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,43 @@
1-
FROM rust:1.83.0-slim-bullseye
1+
# Stage 1: Build watchexec with Rust
2+
FROM rust:1.83.0-slim-bullseye AS rust-builder
23

4+
# Install necessary dependencies for Rust
35
RUN apt-get update -qq && \
4-
apt-get install --no-install-recommends -y build-essential git ruby ruby-dev
6+
apt-get install --no-install-recommends -y build-essential git
57

8+
# Install watchexec
69
RUN cargo install watchexec-cli
10+
11+
# Verify installation
12+
RUN watchexec --version
13+
14+
# Stage 2: Ruby application setup
15+
FROM ruby:2.7-slim-bullseye
16+
17+
# Install necessary dependencies
18+
RUN apt-get update -qq && \
19+
apt-get install --no-install-recommends -y build-essential git && \
20+
apt-get clean && rm -rf /var/lib/apt/lists/*
21+
22+
# Copy watchexec from the Rust stage
23+
COPY --from=rust-builder /usr/local/cargo/bin/watchexec /usr/local/bin/watchexec
24+
25+
# Verify watchexec installation in the final image
726
RUN watchexec --version
827

928
# throw errors if Gemfile has been modified since Gemfile.lock
10-
RUN gem install bundler
1129
RUN bundle config --global frozen 1
1230

1331
WORKDIR /usr/src/app
1432

1533
ENV LANG C.UTF-8
1634
ENV BUNDLER_VERSION 2.1
17-
1835
ENV GEM_HOME="/usr/local/bundle"
1936
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
2037

2138
COPY Gemfile Gemfile.lock retest.gem ./
22-
39+
RUN gem update --system 3.2.3
40+
RUN gem install bundler -v 2.1.4
2341
RUN bundle config --delete frozen
2442
RUN bundle install
2543
RUN gem install retest.gem

0 commit comments

Comments
 (0)