-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "docker-rust" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
actix-web = "4.2.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Use the main rust Docker image(메인 rust 도커 이미지를 사용한다) | ||
FROM rust | ||
# copy app into docker image(app을 도커 이미지에 복사한다) | ||
COPY . /app | ||
# Set the workdirectory(작업 디렉터리를 설정한다) | ||
WORKDIR /app | ||
# build the app(앱을 빌드한다) | ||
RUN cargo build --release | ||
# start the application(애플리케이션을 시작한다) | ||
CMD ["./target/release/docker-rust"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Use the main rust Docker image(메인 rust 도커 이미지를 사용한다) | ||
FROM rust as build | ||
# copy app into docker image(app을 도커 이미지에 복사한다) | ||
COPY . /app | ||
# Set the workdirectory(작업 디렉터리를 설정한다) | ||
WORKDIR /app | ||
# build the app(앱을 빌드한다) | ||
RUN cargo build --release | ||
# start the application(애플리케이션을 시작한다) | ||
|
||
FROM gcr.io/distroless/cc-debian12 | ||
COPY --from=build /app/target/release/docker-rust /app/docker/docker-rust | ||
|
||
CMD ["./app/docker/docker-rust"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Docker-rust | ||
=========== | ||
- build & execution | ||
|
||
``` | ||
docker build -f Dockerfile-basic . -t docker-rust-basic | ||
docker run -p 8080:8080 -t docker-rust-basic | ||
docker build -f Dockerfile-lite . -t docker-rust-lite | ||
docker run -p 8080:8080 -t docker-rust-lite | ||
``` | ||
-  | ||
- Necessary to use appropriate version, e.g. when using `cc-debian11`, got this error | ||
-  |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use actix_web::{get, web, App, HttpResponse, HttpServer, Responder}; | ||
#[get("/")] | ||
async fn gm() -> impl Responder { | ||
HttpResponse::Ok().body("Hello, Good morning!") | ||
} | ||
async fn hello() -> impl Responder { | ||
HttpResponse::Ok().body("Hello there!") | ||
} | ||
#[actix_web::main] | ||
async fn main() -> std::io::Result<()> { | ||
HttpServer::new(|| { | ||
App::new() | ||
.service(gm) | ||
.route("/hello", web::get().to(hello)) | ||
}) | ||
.bind(("0.0.0.0", 8080))? | ||
.run() | ||
.await | ||
} |