This commit is contained in:
Timofey Gelazoniya 2023-04-08 17:38:51 +03:00
parent e548f1b268
commit 63a4d7ac32
Signed by: zeldon
GPG Key ID: 047886915281DD2A
5 changed files with 59 additions and 1 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
target
.env
Dockerfile

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/target /target
.env .env
docker-compose.prod.yml

40
Dockerfile Normal file
View 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
View 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
View File

@ -0,0 +1 @@
fn main() {}