Added Docker build files
This commit is contained in:
parent
f69e489f28
commit
b49a01ab03
3 changed files with 33 additions and 0 deletions
8
.dockerignore
Normal file
8
.dockerignore
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
*
|
||||
|
||||
# Source code
|
||||
!src/
|
||||
|
||||
# Cargo files
|
||||
!Cargo.toml
|
||||
!Cargo.lock
|
||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# syntax=docker/dockerfile:1.2
|
||||
FROM rustlang/rust:nightly AS builder
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Build the app
|
||||
COPY . .
|
||||
RUN --mount=type=cache,target=/usr/src/app/target cargo install --path .
|
||||
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
||||
COPY --from=builder /usr/local/cargo/bin/rust-api /usr/local/bin/rust-api
|
||||
|
||||
CMD ["rust-api"]
|
||||
10
Makefile
10
Makefile
|
|
@ -1,3 +1,8 @@
|
|||
IMAGE := rust_api:latest
|
||||
|
||||
shell := /bin/bash
|
||||
|
||||
|
||||
all: debug
|
||||
.PHONY: all
|
||||
|
||||
|
|
@ -10,7 +15,12 @@ release:
|
|||
@ cargo build --release
|
||||
.PHONY: release
|
||||
|
||||
image: Dockerfile
|
||||
@ DOCKER_BUILDKIT=1 docker build -t '$(IMAGE)' .
|
||||
.PHONY: image
|
||||
|
||||
|
||||
# Run
|
||||
run:
|
||||
@ cargo run
|
||||
|
||||
|
|
|
|||
Reference in a new issue