diff --git a/config.yaml b/config.yaml index 5c7cc0cb..db7be989 100644 --- a/config.yaml +++ b/config.yaml @@ -1,3 +1,3 @@ -address: 0.0.0.0:7000 +address: 0.0.0.0:9000 logger: trace-level: INFO diff --git a/docker-compose.yaml b/docker-compose.yaml index 90f3f967..17fa10a1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,21 +5,14 @@ services: build: context: ./ dockerfile: dockerfiles/alpine/Dockerfile + volumes: + - "./config.yaml:/config.yaml" networks: bobnet: ipv4_address: 192.168.17.11 ports: - "9000:9000" - command: "backend/backend --config-file config" - bob-gui-dev: - build: - context: ./ - dockerfile: dockerfiles/alpine/Dockerfile.dev - networks: - bobnet: - ipv4_address: 192.168.17.12 - ports: - - "8000:9000" + command: "--config-file /config.yaml" networks: bobnet: driver: bridge diff --git a/dockerfiles/alpine/Dockerfile b/dockerfiles/alpine/Dockerfile index 82b9ffa0..c18552ad 100644 --- a/dockerfiles/alpine/Dockerfile +++ b/dockerfiles/alpine/Dockerfile @@ -15,18 +15,26 @@ RUN apt-get update \ # RUN USER=root cargo new --bin bob-management -COPY ./Cargo.toml ./Cargo.toml -COPY ./build.rs ./build.rs -COPY ./cli ./cli -COPY ./backend ./backend -COPY ./.cargo ./.cargo -RUN cargo backend --profile=$BUILD_PROFILE --target=$BUILD_TARGET +RUN mkdir -p backend/src frontend cli/src +RUN mkdir target +COPY Cargo.toml Cargo.toml +COPY cli/Cargo.toml cli/Cargo.toml +COPY backend/Cargo.toml backend/Cargo.toml +COPY frontend/Cargo.toml frontend/Cargo.toml +COPY .cargo .cargo +RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > backend/src/lib.rs \ + && echo "fn main() {println!(\"if you see this, the build broke\")}" > backend/src/main.rs \ + && echo "fn main() {println!(\"if you see this, the build broke\")}" > frontend/build.rs \ + && echo "fn main() {println!(\"if you see this, the build broke\")}" > cli/src/lib.rs \ + && echo "fn main() {println!(\"if you see this, the build broke\")}" > build.rs \ + && cargo build -p bob_management --features backend --no-default-features --profile=$BUILD_PROFILE --target=$BUILD_TARGET ADD . ./ -RUN --mount=type=cache,target=/usr/local/cargo/registry \ - --mount=type=cache,target=/home/root/app/target \ - cargo backend --profile=$BUILD_PROFILE --target=$BUILD_TARGET \ +RUN \ + # --mount=type=cache,target=/usr/local/cargo/registry \ + # --mount=type=cache,target=/home/root/app/target \ + cargo build -p bob_management --features backend --no-default-features --profile=$BUILD_PROFILE --target=$BUILD_TARGET \ && mkdir /build_output \ && cp -f target/$BUILD_TARGET/$BUILD_PROFILE/backend /build_output/backend @@ -40,7 +48,7 @@ FROM alpine:3.18 ARG APP=/usr/src/app ENV TZ=Etc/UTC \ APP_USER=appuser - +ENV PATH="$PATH:${APP}" RUN addgroup -S $APP_USER \ && adduser -S -g $APP_USER $APP_USER \ && apk update \ @@ -49,11 +57,11 @@ RUN addgroup -S $APP_USER \ EXPOSE 9000 -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 +COPY --from=backend --chown=$APP_USER:$APP_USER /build_output/backend ${APP}/backend +COPY --from=frontend --chown=$APP_USER:$APP_USER /frontend/dist ${APP}/dist USER $APP_USER WORKDIR ${APP} -CMD ["./backend/backend"] +ENTRYPOINT ["./backend"] diff --git a/dockerfiles/alpine/Dockerfile.dev b/dockerfiles/alpine/Dockerfile.dev deleted file mode 100644 index 61ed177a..00000000 --- a/dockerfiles/alpine/Dockerfile.dev +++ /dev/null @@ -1,73 +0,0 @@ -FROM rust:1.72 as builder - -ENV HOME=/home/root -WORKDIR $HOME/app -# rust toolchain -ARG RUST_TC_VER=stable -ARG BUILD_TARGET=x86_64-unknown-linux-musl -ARG BUILD_PROFILE=dev - -# 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 \ - && rustup install $RUST_TC_VER \ - && rustup default $RUST_TC_VER \ - && rustup target add $BUILD_TARGET - - -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 - -ADD . ./ - -RUN rm ./target/$BUILD_TARGET/debug/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 \ - && mkdir /build_output \ - && mkdir /build_output/backend \ - && mkdir /build_output/frontend \ - && cp -f target/$BUILD_TARGET/debug/bob_management /build_output/backend/bob_management \ - && cp -r -f target/frontend/dist /build_output/frontend/dist - -FROM alpine:3.18 -ARG APP=/usr/src/app -ENV TZ=Etc/UTC \ - APP_USER=appuser - -RUN addgroup -S $APP_USER \ - && adduser -S -g $APP_USER $APP_USER \ - && apk update \ - && apk add --no-cache ca-certificates tzdata \ - && rm -rf /var/cache/apk/* - -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 - -USER $APP_USER -WORKDIR ${APP} - -CMD ["./backend/bob_management", "--default"] -