Skip to content

fix: cross-platform Docker build for ARM64 and AMD64 - #125

Open
gudmeong wants to merge 5 commits into
MrMissx:masterfrom
gudmeong:master
Open

fix: cross-platform Docker build for ARM64 and AMD64#125
gudmeong wants to merge 5 commits into
MrMissx:masterfrom
gudmeong:master

Conversation

@gudmeong

Copy link
Copy Markdown
Contributor

No description provided.

@gudmeong
gudmeong requested a review from MrMissx as a code owner July 26, 2026 19:21
@MrMissx

MrMissx commented Jul 27, 2026

Copy link
Copy Markdown
Owner

udh bener ga usah dihapus ini 🙃#124

tinggal

docker build \
  --build-arg ARCH=linux/arm64 \
  -t .

@gudmeong

Copy link
Copy Markdown
Contributor Author

udh bener ga usah dihapus ini 🙃#124

tinggal

docker build \
  --build-arg ARCH=linux/arm64 \
  -t .

error cok, w deploy baru.

ni baru

@MrMissx

MrMissx commented Jul 27, 2026

Copy link
Copy Markdown
Owner

gantiin gini aja @gudmeong

FROM --platform=$BUILDPLATFORM golang:1.25 AS build

WORKDIR /app

RUN apt-get update && \
    apt-get install -y --no-install-recommends ca-certificates curl gnupg make && \
    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN npm i -g pnpm

COPY Makefile ./
COPY go.mod go.sum package.json pnpm-lock.yaml ./

RUN make install
RUN go mod verify
RUN go install github.com/a-h/templ/cmd/templ@latest

COPY . .

# Cross-compile the Go binary for the target platform
ARG TARGETOS
ARG TARGETARCH
RUN make generate
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build


FROM debian:bookworm-slim AS runner

WORKDIR /app

COPY --from=build /app/stashbin .
COPY --from=build /app/public ./public
COPY ./database/migrations ./database/migrations

CMD ["./stashbin"]
docker buildx build --platform linux/amd64 -t stashbin:latest .
image

@gudmeong

Copy link
Copy Markdown
Contributor Author

gantiin gini aja @gudmeong

FROM --platform=$BUILDPLATFORM golang:1.25 AS build

WORKDIR /app

RUN apt-get update && \
    apt-get install -y --no-install-recommends ca-certificates curl gnupg make && \
    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN npm i -g pnpm

COPY Makefile ./
COPY go.mod go.sum package.json pnpm-lock.yaml ./

RUN make install
RUN go mod verify
RUN go install github.com/a-h/templ/cmd/templ@latest

COPY . .

# Cross-compile the Go binary for the target platform
ARG TARGETOS
ARG TARGETARCH
RUN make generate
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build


FROM debian:bookworm-slim AS runner

WORKDIR /app

COPY --from=build /app/stashbin .
COPY --from=build /app/public ./public
COPY ./database/migrations ./database/migrations

CMD ["./stashbin"]
docker buildx build --platform linux/amd64 -t stashbin:latest .
image

dh coba cek ung

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants