Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 committed Oct 24, 2024
1 parent 3627cbf commit dbf939f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,10 @@ jobs:
build:
runs-on: ubuntu-latest # Use Ubuntu for building the project

strategy:
matrix:
target: [x86_64-unknown-linux-gnu]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true

- name: Install cross (for cross-compilation)
run: cargo install cross --version 0.2.5

- name: Build project
run: cross build --target ${{ matrix.target }} --release

- uses: docker/login-action@v3
with:
registry: ghcr.io
Expand Down
29 changes: 23 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
# Stage 1: Build the Rust binaries
FROM docker.io/rust:1-slim-bookworm as cargo-build
WORKDIR /src/

# Install dependencies
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update && \
apt-get install -y git libssl-dev pkg-config git
apt-get install -y git libssl-dev pkg-config

# Copy the binary from the `cross` build (adjust the path to your binary)
COPY target/x86_64-unknown-linux-gnu/release/data-migration /app/data-migration
# Copy the source code into the container
COPY . .

# Build the application
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/src/target \
CARGO_PROFILE_RELEASE_DEBUG=1 cargo build --release

# Stage 2: Create an intermediate image for dependencies
FROM docker.io/debian:bookworm-slim as intermediate
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked apt-get update && \
apt-get install -y ca-certificates tini gettext-base && \
apt-get clean

# Stage 3: Create the final image
FROM intermediate as final
RUN apt-get update && \
apt-get install -y build-essential cmake git zlib1g-dev libelf-dev libdw-dev libboost-dev libboost-iostreams-dev libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libunwind-dev libzstd-dev git
COPY --from=cargo-build /src/target/release/data-migration /usr/local/bin/data-migration

# Ensure the binary is executable
RUN chmod +x /app/data-migration
RUN chmod +x /usr/local/bin/data-migration

# Set the binary as the entrypoint
ENTRYPOINT ["/app/data-migration"]
# Set the entrypoint for the container
ENTRYPOINT ["/usr/local/bin/data-migration"]

0 comments on commit dbf939f

Please sign in to comment.