build #2
16
Dockerfile
16
Dockerfile
@ -5,16 +5,20 @@ COPY frontend/ .
|
|||||||
RUN npm install
|
RUN npm install
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Build the Rust backend
|
# Stage 2: Build the Rust backend (statically linked)
|
||||||
FROM rust:1.83 as backend-builder
|
FROM rust:1.83 as backend-builder
|
||||||
WORKDIR /app/backend
|
WORKDIR /app/backend
|
||||||
COPY backend/ .
|
COPY backend/ .
|
||||||
RUN cargo build --release
|
# Add the musl target for static linking
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
# Build the binary with musl
|
||||||
|
RUN cargo build --release --target x86_64-unknown-linux-musl
|
||||||
|
|
||||||
# Final Stage: Combine frontend and backend
|
# Final Stage
|
||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=frontend-builder /app/frontend/build ./frontend/dist
|
COPY --from=frontend-builder /app/frontend/build ./frontend/build
|
||||||
COPY --from=backend-builder /app/backend/target/release/formies_be ./formies_be
|
# Copy the statically linked binary
|
||||||
|
COPY --from=backend-builder /app/backend/target/x86_64-unknown-linux-musl/release/formies_be ./formies_be
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
CMD ["./backend"]
|
CMD ["./formies_be"]
|
@ -24,7 +24,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.allow_any_method(),
|
.allow_any_method(),
|
||||||
)
|
)
|
||||||
.app_data(web::Data::new(db.clone()))
|
.app_data(web::Data::new(db.clone()))
|
||||||
.service(fs::Files::new("/", "./frontend/dist").index_file("index.html"))
|
.service(fs::Files::new("/", "frontend/build").index_file("index.html"))
|
||||||
.route("/login", web::post().to(handlers::login)) // Public: Login
|
.route("/login", web::post().to(handlers::login)) // Public: Login
|
||||||
.route(
|
.route(
|
||||||
"/forms/{id}/submissions",
|
"/forms/{id}/submissions",
|
||||||
@ -37,7 +37,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
web::get().to(handlers::get_submissions), // Protected
|
web::get().to(handlers::get_submissions), // Protected
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8080")?
|
.bind("0.0.0.0:8080")?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user