Skip to content

Commit 1231c63

Browse files
committed
Re-introduce Dockerfile with multi-stage runtime image to decrease size
1 parent 06e906c commit 1231c63

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

‎Dockerfile‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
# First stage: build the application
2-
FROM rust:1.88 as builder
2+
FROM rust:1.88 AS builder
33

4-
RUN apt-get update && apt-get install -y \
4+
WORKDIR /httpmock
5+
6+
COPY Cargo.toml .
7+
# COPY Cargo.lock .
8+
9+
COPY src/ ./src/
10+
COPY certs/ ./certs/
11+
12+
RUN cargo install --all-features --path .
13+
14+
FROM debian:trixie-slim
15+
16+
# hadolint ignore=DL3008
17+
RUN apt-get update && apt-get install -y --no-install-recommends \
518
ca-certificates \
619
&& rm -rf /var/lib/apt/lists/*
720

21+
COPY --from=builder /usr/local/cargo/bin/httpmock /usr/local/bin/httpmock
22+
823
# Log level (refer to env_logger crate for more information)
9-
ENV RUST_LOG httpmock=info
24+
ENV RUST_LOG=httpmock=info
1025

1126
# The TCP port on which the mock server will listen to.
12-
ENV HTTPMOCK_PORT 5050
27+
ENV HTTPMOCK_PORT=5050
1328

1429
# Container internal directory path that contains file bases mock specs (YAML-fies).
15-
# ENV HTTPMOCK_MOCK_FILES_DIR /mocks
30+
# ENV HTTPMOCK_MOCK_FILES_DIR=/mocks
1631

1732
# The existence of this environment variable (even if value is empty) is considered "true"/"disabled".
18-
# ENV HTTPMOCK_DISABLE_ACCESS_LOG true
33+
# ENV HTTPMOCK_DISABLE_ACCESS_LOG=true
1934

2035
# Request history limit.
21-
ENV HTTPMOCK_REQUEST_HISTORY_LIMIT 100
22-
23-
WORKDIR /httpmock
24-
25-
COPY Cargo.toml .
26-
# COPY Cargo.lock .
27-
28-
COPY src/ ./src/
29-
COPY certs/ ./certs/
30-
31-
RUN cargo install --all-features --path .
36+
ENV HTTPMOCK_REQUEST_HISTORY_LIMIT=100
3237

3338
ENTRYPOINT ["httpmock", "--expose"]
3439

0 commit comments

Comments
 (0)