Skip to content

Commit

Permalink
optimizing build
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBANCHEREAU committed Nov 1, 2023
1 parent f9ff051 commit 1dd655c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 41 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
docker:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
Expand All @@ -29,6 +29,22 @@ jobs:
with:
images: ghcr.io/${{ github.repository }}

- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install build deps
run: cargo install cargo-make trunk && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && rustup target add wasm32-unknown-unknown

- name: Build
run: cargo make build

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
Expand All @@ -43,4 +59,4 @@ jobs:
host: ${{ secrets.SSH_HOSTNAME }}
username: ${{ secrets.SSH_USER }}
password: ${{ secrets.SSH_PASSWORD }}
script: cd minesweeper-rs && docker compose up -d
script: cd minesweeper-rs && docker compose pull && docker compose up -d
23 changes: 4 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
FROM rust:bookworm as builder
FROM debian:bookworm

RUN cargo install cargo-make trunk
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN rustup target add wasm32-unknown-unknown
COPY ./client/dist client/dist
COPY ./client/images client/images

WORKDIR /build
COPY core core
COPY model model
COPY client client
COPY server server
COPY Cargo.toml .

RUN cargo make build

FROM debian:bookworm as runner

COPY --from=builder /build/client/dist client/dist
COPY --from=builder /build/client/images client/images

COPY --from=builder /build/target/release/server server/server
COPY ./target/release/server server/server

EXPOSE 9000

Expand Down
20 changes: 0 additions & 20 deletions package.json

This file was deleted.

0 comments on commit 1dd655c

Please sign in to comment.