Dockerfile fixes & moved to Scratch Image
This commit is contained in:
		
							
								
								
									
										24
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -1,31 +1,31 @@ | ||||
| FROM rust:1-trixie as builder | ||||
|  | ||||
| RUN apt-get update && apt-get install -y libpq-dev pkg-config | ||||
| RUN rustup target add x86_64-unknown-linux-musl | ||||
|  | ||||
| RUN apt-get update && apt-get install -y musl-tools musl-dev | ||||
|  | ||||
| WORKDIR /usr/src/app | ||||
|  | ||||
| RUN cargo init --bin . | ||||
| COPY ./Cargo.toml ./ | ||||
|  | ||||
| RUN cargo build --release | ||||
| RUN rm src/*.rs | ||||
| RUN mkdir src && echo "fn main(){}" > src/main.rs | ||||
| RUN cargo build --release --target x86_64-unknown-linux-musl | ||||
|  | ||||
| COPY ./src ./src | ||||
| COPY ./static ./static | ||||
| COPY ./migrations ./migrations | ||||
| COPY ./static ./static | ||||
|  | ||||
| RUN cargo build --release | ||||
| RUN touch src/main.rs && cargo build --release --target x86_64-unknown-linux-musl | ||||
|  | ||||
| FROM debian:trixie-slim | ||||
| FROM scratch | ||||
|  | ||||
| # RUN apt-get update && apt-get install -y ca-certificates libpq5 && rm -rf /var/lib/apt/lists/* | ||||
| WORKDIR /app | ||||
|  | ||||
| WORKDIR /usr/src/app | ||||
|  | ||||
| COPY --from=builder /usr/src/app/target/release/shortlink-rs . | ||||
| COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/shortlink-rs . | ||||
|  | ||||
| COPY --from=builder /usr/src/app/static ./static | ||||
|  | ||||
| COPY --from=builder /usr/src/app/migrations ./migrations | ||||
|  | ||||
| EXPOSE 3000 | ||||
|  | ||||
| CMD ["./shortlink-rs"] | ||||
		Reference in New Issue
	
	Block a user