Docker
This commit is contained in:
parent
e548f1b268
commit
63a4d7ac32
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
target
|
||||
.env
|
||||
Dockerfile
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/target
|
||||
.env
|
||||
.env
|
||||
docker-compose.prod.yml
|
40
Dockerfile
Normal file
40
Dockerfile
Normal file
@ -0,0 +1,40 @@
|
||||
FROM fedora:38 as build
|
||||
ENV PKG_CONFIG_ALLOW_CROSS=1
|
||||
|
||||
RUN dnf install -y rust cargo ImageMagick-devel clang --setopt=install_weak_deps=False
|
||||
|
||||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
||||
|
||||
WORKDIR /usr/src/liquid-rescale-api
|
||||
|
||||
# Download and compile deps
|
||||
COPY Cargo.toml .
|
||||
COPY Cargo.lock .
|
||||
COPY docker_utils/dummy.rs .
|
||||
# Change temporarely the path of the code
|
||||
RUN sed -i 's|src/main.rs|dummy.rs|' Cargo.toml
|
||||
# Build only deps
|
||||
RUN cargo build --release
|
||||
# Now return the file back to normal
|
||||
RUN sed -i 's|dummy.rs|src/main.rs|' Cargo.toml
|
||||
|
||||
# Copy everything
|
||||
COPY . .
|
||||
# Add the wait script
|
||||
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
|
||||
RUN chmod +x /wait
|
||||
# Build our code
|
||||
RUN cargo build --release
|
||||
|
||||
FROM fedora:38
|
||||
|
||||
RUN dnf install -y ImageMagick-devel --setopt=install_weak_deps=False \
|
||||
&& dnf clean all \
|
||||
&& rm -rf /var/cache/yum
|
||||
|
||||
COPY --from=build /usr/src/liquid-rescale-api/target/release/liquid-rescale-api /liquid-rescale-api/liquid-rescale-api
|
||||
COPY --from=build /wait /wait
|
||||
|
||||
WORKDIR /liquid-rescale-api
|
||||
|
||||
CMD /wait && /liquid-rescale-api/liquid-rescale-api
|
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@ -0,0 +1,13 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
liquid-rescale-api:
|
||||
container_name: 'liquid-rescale-api'
|
||||
environment:
|
||||
PORT: 3021
|
||||
ports:
|
||||
- 3021:3021
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
restart: unless-stopped
|
1
docker_utils/dummy.rs
Normal file
1
docker_utils/dummy.rs
Normal file
@ -0,0 +1 @@
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user