From 1789ce55af623abd591b29c112367faff28db845 Mon Sep 17 00:00:00 2001 From: Simeon Romanov Date: Sun, 17 Sep 2023 13:01:05 +0300 Subject: [PATCH] some changes --- docker-compose.yaml | 1 + dockerfiles/alpine/Dockerfile | 45 ++++++++++++----------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 443135ef..90f3f967 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,6 +10,7 @@ services: ipv4_address: 192.168.17.11 ports: - "9000:9000" + command: "backend/backend --config-file config" bob-gui-dev: build: context: ./ diff --git a/dockerfiles/alpine/Dockerfile b/dockerfiles/alpine/Dockerfile index 5479d525..82b9ffa0 100644 --- a/dockerfiles/alpine/Dockerfile +++ b/dockerfiles/alpine/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.72 as builder +FROM rust:1.72 as backend ENV HOME=/home/root WORKDIR $HOME/app @@ -7,23 +7,8 @@ ARG RUST_TC_VER=stable ARG BUILD_TARGET=x86_64-unknown-linux-musl ARG BUILD_PROFILE=release-lto -# import the Nodesource GPG key RUN apt-get update \ - && apt-get install -y ca-certificates curl gnupg \ - && mkdir -p /etc/apt/keyrings \ - && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg - -# Create deb repository -# FIXME: Replace it with Nodejs 20.x when it will be fixed -ENV NODE_MAJOR=18 -RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list - -# Install yarn keys -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \ - && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - -RUN apt-get update \ - && apt-get install -y --no-install-recommends musl-tools yarn nodejs \ + && apt-get install -y --no-install-recommends musl-tools \ && rustup install $RUST_TC_VER \ && rustup default $RUST_TC_VER \ && rustup target add $BUILD_TARGET @@ -34,22 +19,22 @@ COPY ./Cargo.toml ./Cargo.toml COPY ./build.rs ./build.rs COPY ./cli ./cli COPY ./backend ./backend -COPY ./frontend ./frontend -RUN cargo build --profile=$BUILD_PROFILE --target=$BUILD_TARGET --bin bob_management -RUN find . -name '*.rs' -delete +COPY ./.cargo ./.cargo +RUN cargo backend --profile=$BUILD_PROFILE --target=$BUILD_TARGET ADD . ./ -RUN rm ./target/$BUILD_TARGET/$BUILD_PROFILE/deps/bob_management* - RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/home/root/app/target \ - cargo build --profile=$BUILD_PROFILE --target=$BUILD_TARGET --bin bob_management \ + cargo backend --profile=$BUILD_PROFILE --target=$BUILD_TARGET \ && mkdir /build_output \ - && mkdir /build_output/backend \ - && mkdir /build_output/frontend \ - && cp -f target/$BUILD_TARGET/$BUILD_PROFILE/bob_management /build_output/backend/bob_management \ - && cp -r -f target/frontend/dist /build_output/frontend/dist + && cp -f target/$BUILD_TARGET/$BUILD_PROFILE/backend /build_output/backend + +FROM node:20.6 as frontend + +COPY ./frontend ./frontend + +RUN cd frontend && yarn && yarn build FROM alpine:3.18 ARG APP=/usr/src/app @@ -64,11 +49,11 @@ RUN addgroup -S $APP_USER \ EXPOSE 9000 -COPY --from=builder --chown=$APP_USER:$APP_USER /build_output/backend ${APP}/backend -COPY --from=builder --chown=$APP_USER:$APP_USER /build_output/frontend ${APP}/frontend +COPY --from=backend --chown=$APP_USER:$APP_USER /build_output/backend ${APP}/backend/backend +COPY --from=frontend --chown=$APP_USER:$APP_USER /frontend/dist ${APP}/frontend USER $APP_USER WORKDIR ${APP} -CMD ["./backend/bob_management", "--default"] +CMD ["./backend/backend"]