Skip to content

Commit

Permalink
feat: build arm
Browse files Browse the repository at this point in the history
  • Loading branch information
Alw3ys authored Mar 15, 2024
1 parent 88025d2 commit f145f2e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 33 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,24 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
platforms: linux/amd64,linux/arm64

- name: Docker Build
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: doseiai/dosei
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
load: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker Push
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["proto", "doseid", "proxy", "util", 'dctl']
resolver = "2"

[workspace.package]
version = "0.0.18"
version = "0.0.19"
license = "Apache-2.0"
repository = "https://github.com/doseiai/dosei"
authors = [
Expand Down
49 changes: 28 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
FROM rust:1.76.0 as builder
ARG RUST_VERSION=1.76.0
FROM lukemathwalker/cargo-chef:0.1.66-rust-$RUST_VERSION as chef

ENV SQLX_OFFLINE=true
WORKDIR /dosei

WORKDIR /usr/src/dosei

RUN apt-get update && apt-get install -y build-essential protobuf-compiler python3.11-dev

FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json

RUN --mount=type=cache,target=target cargo build --release
FROM chef AS builder

RUN mkdir release
RUN --mount=type=cache,target=target cp target/release/doseid release/doseid
RUN --mount=type=cache,target=target cp target/release/dctl release/dctl
RUN --mount=type=cache,target=target cp target/release/proxy release/proxy
RUN apt-get update && apt-get install build-essential protobuf-compiler python3.11-dev -y

COPY --from=planner /dosei/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build Dosei
COPY . .
RUN cargo build --release

FROM rust:1.76.0
FROM debian:12-slim AS runtime

RUN apt-get update && apt-get install -y python3.11-dev
LABEL org.opencontainers.image.title="Dosei"
LABEL org.opencontainers.image.description="Official Dosei image"
LABEL org.opencontainers.image.url="https://dosei.ai"
LABEL org.opencontainers.image.documentation="https://dosei.ai/docs"
LABEL org.opencontainers.image.source="https://github.com/doseiai/dosei"
LABEL org.opencontainers.image.vendor="Dosei"

ARG RELEASE_PATH=/usr/src/dosei/release
ARG DOSEID_INSTALL=/bin/doseid
ARG DOSEI_CLI_INSTALL=/bin/dctl
ARG DOSEI_PROXY_INSTALL=/bin/dosei-proxy
RUN apt-get update && apt-get install python3.11-dev -y

COPY --from=builder ${RELEASE_PATH}/doseid ${DOSEID_INSTALL}
COPY --from=builder ${RELEASE_PATH}/dctl ${DOSEI_CLI_INSTALL}
COPY --from=builder ${RELEASE_PATH}/proxy ${DOSEI_PROXY_INSTALL}
ARG RELEASE_PATH=/dosei/target/release
ARG TAGET_PATH=/usr/local/bin

RUN chmod +x ${DOSEID_INSTALL} ${DOSEI_CLI_INSTALL} ${DOSEI_PROXY_INSTALL}
COPY --from=builder $RELEASE_PATH/doseid $TAGET_PATH
COPY --from=builder $RELEASE_PATH/dctl $TAGET_PATH
COPY --from=builder $RELEASE_PATH/proxy $TAGET_PATH

CMD ["/bin/doseid"]
ENTRYPOINT ["/usr/local/bin/doseid"]

0 comments on commit f145f2e

Please sign in to comment.