Skip to content

Commit

Permalink
added building of frontend in dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
lololozhkin committed Oct 30, 2023
1 parent 2652628 commit 14b4edc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions services/rustest/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/**/target/
/**/build/
/**/node_modules/
19 changes: 19 additions & 0 deletions services/rustest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ COPY ./src ./src
RUN rm ./target/release/deps/rustest-* && \
cargo build --release

###############################################################

FROM node:18.18.2-alpine as front_builder

WORKDIR /front

COPY ./front/package*.json ./

RUN npm install

COPY ./front/src ./src/
COPY ./front/public ./public

RUN npm run build

################################################################

FROM debian:buster-slim
ARG APP=/usr/src/app

Expand All @@ -32,6 +49,8 @@ RUN groupadd $APP_USER \

COPY --from=builder /rustest/target/release/rustest ${APP}/rustest

COPY --from=front_builder /front/ ${APP}/front

RUN chown -R $APP_USER:$APP_USER ${APP}

USER $APP_USER
Expand Down
2 changes: 1 addition & 1 deletion services/rustest/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub fn build_router(state: AppState) -> Router {
.merge(unauthenticated_routes);

let serve_dir =
ServeDir::new("static").not_found_service(ServeFile::new("static/index.html"));
ServeDir::new("front/build").not_found_service(ServeFile::new("front/build/index.html"));

ApiRouter::new()
.nest("/api", merged_api)
Expand Down

0 comments on commit 14b4edc

Please sign in to comment.