Skip to content

Commit

Permalink
Merge pull request #3 from benzlokzik/dev
Browse files Browse the repository at this point in the history
Added dockerfile
  • Loading branch information
benzlokzik committed Nov 6, 2023
2 parents 0e597cc + c65aa7c commit e6eb4e5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# official Rust image as a builder
FROM rust:1.70 as builder

# new empty project
RUN USER=root cargo new --bin app
WORKDIR /app

# copy my manifests
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml

# build only the dependencies to cache them
RUN cargo build --release
RUN rm src/*.rs

# copy the source code
COPY ./src ./src

# remove the dummy target
RUN rm ./target/release/deps/fahrenheit_celsius_kelvin_converter*

# set the build to be statically linked
RUN RUSTFLAGS='-C target-feature=+crt-static'

# build for release
RUN cargo build --release

# final base image, use the same Debian version as the builder
FROM debian:bullseye-slim

# copy the build artifact from the build stage
COPY --from=builder /app/target/release/fahrenheit_celsius_kelvin_converter .

# set the startup command to run binary
CMD ["./fahrenheit_celsius_kelvin_converter"]
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ Simple http Fahrenheit/Celsius/Kelvin converter using [actix-web](https://actix.

---

> [!WARNING]\
> [!NOTE]\
> This is a toy project, not yet finished. It's not recommended to use it in production.

## Usage

From terminal:

```bash
git clone https://github.com/benzlokzik/fahrenheit-celsius-converter/
cd fahrenheit-celsius-converter
cargo build
cargo run
```

Via Docker:

```bash
docker build -t fahrenheit-celsius-converter .
docker run -p 8080:8080 fahrenheit-celsius-converter
```

0 comments on commit e6eb4e5

Please sign in to comment.