Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
archeoss committed Sep 19, 2023
1 parent 002b86d commit 1789ce5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ./
Expand Down
45 changes: 15 additions & 30 deletions dockerfiles/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.72 as builder
FROM rust:1.72 as backend

ENV HOME=/home/root
WORKDIR $HOME/app
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"]

0 comments on commit 1789ce5

Please sign in to comment.