Skip to content

Commit

Permalink
Multiplatform Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
windoze committed Jan 2, 2024
1 parent d5a72c8 commit a7f3b64
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
platforms: linux/amd64,linux/arm64,linux/armv7
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}, windoze/clip-sync-server:latest, windoze/clip-sync-server:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
28 changes: 18 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
ARG TARGETARCH

FROM --platform=$BUILDPLATFORM rust:alpine AS builder
ENV OPENSSL_STATIC=yes
RUN apk add musl-dev alpine-sdk perl clang lld && rustup target add wasm32-unknown-unknown && cargo install dioxus-cli
FROM messense/rust-musl-cross:x86_64-musl-amd64 AS builder-amd64
FROM messense/rust-musl-cross:aarch64-musl-amd64 AS builder-arm64

FROM builder-${TARGETARCH} as builder
ARG TARGETARCH
ARG TARGETPLATFORM
WORKDIR /usr/src/clip-sync
COPY --from=xx / /
WORKDIR /usr/src/
COPY . ./
RUN cargo build --release --no-default-features --features server-only --target=$(xx-info march)-unknown-linux-musl && \
cp /usr/src/target/$(xx-info march)-unknown-linux-musl/release/clip-sync /

FROM rust:buster AS ui-builder
WORKDIR /usr/src/clip-sync
COPY . .
RUN xx-cargo build --release --no-default-features --features server-only && \
cd clip-sync-ui && dx build --release
RUN rustup target add wasm32-unknown-unknown && cargo install dioxus-cli
RUN cd clip-sync-ui && dx build --release

FROM --platform=$BUILDPLATFORM alpine
FROM alpine
RUN apk add --update openssl bash
RUN mkdir /index
COPY --from=builder /usr/src/clip-sync/target/release/clip-sync /app/clip-sync
COPY --from=builder /usr/src/clip-sync/config-server.toml /config/config.toml
COPY --from=builder /usr/src/clip-sync/clip-sync-ui/dist /static-files
COPY --from=builder /clip-sync /app/clip-sync
COPY --from=builder /usr/src/config.toml /config/config.toml
COPY --from=ui-builder /usr/src/clip-sync/clip-sync-ui/dist /static-files
EXPOSE 3000
WORKDIR /
CMD ["/app/clip-sync", "--config", "/config/config.toml"]
3 changes: 1 addition & 2 deletions config-server.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
roles = ["server"]

[server]
endpoint = "0.0.0.0:3000"
index-path = "/index"

0 comments on commit a7f3b64

Please sign in to comment.