-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created Makefile - Updated readme
- Loading branch information
Showing
4 changed files
with
53 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ go.work.sum | |
# env file | ||
.env | ||
|
||
dist/ | ||
downloads/ | ||
torrents/ | ||
*.torrent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
FROM golang:1.23.3 as builder | ||
|
||
# Build binary | ||
FROM --platform=$BUILDPLATFORM golang:1.23.3-alpine AS build-env | ||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
# Copy the go sources | ||
COPY . . | ||
|
||
# Build | ||
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o ghostbox GhostBox.go | ||
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o ghostbox GhostBox.go | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ | ||
go build -ldflags="-s -w" -o ghostbox GhostBox.go | ||
|
||
RUN mkdir torrents downloads | ||
|
||
|
||
# Create image | ||
# Use distroless as minimal base image to package the manager binary | ||
FROM alpine:latest | ||
# Create the /torrents and /downloads directories | ||
FROM scratch | ||
WORKDIR /app | ||
RUN mkdir torrents downloads | ||
COPY --from=builder /workspace/ghostbox . | ||
COPY --from=build-env /workspace/ghostbox . | ||
COPY --from=build-env /workspace/torrents . | ||
COPY --from=build-env /workspace/downloads . | ||
CMD [ "/app/ghostbox", "-i", "/app/torrents", "-o", "/app/downloads" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.DEFAULT_GOAL := default | ||
|
||
IMAGE ?= xnonames/ghostbox:latest | ||
|
||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
.PHONY: build # Build the container image | ||
build: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--output "type=docker,push=false" \ | ||
--tag $(IMAGE) \ | ||
. | ||
|
||
.PHONY: publish # Push the image to the remote registry | ||
publish: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm/v8,linux/arm64,linux/ppc64le,linux/s390x \ | ||
--output "type=image,push=true" \ | ||
--tag $(IMAGE) \ | ||
. | ||
|
||
|
||
.PHONY: generate | ||
generate: | ||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o dist/ghostbox_linux_i386 GhostBox.go # Linux 32bit | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/ghostbox_linux_x86_64 GhostBox.go # Linux 64bit | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/ghostbox_linux_arm GhostBox.go # Linux armv5/armel/arm (it also works on armv6) | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/ghostbox_linux_armhf GhostBox.go # Linux armv7/armhf | ||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o dist/ghostbox_linux_aarch64 GhostBox.go # Linux armv8/aarch64 | ||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o dist/ghostbox_freebsd_x86_64 GhostBox.go # FreeBSD 64bit | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/ghostbox_darwin_x86_64 GhostBox.go # Darwin 64bit | ||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/ghostbox_darwin_aarch64 GhostBox.go # Darwin armv8/aarch64 | ||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o dist/ghostbox_windows_i386.exe GhostBox.go # Windows 32bit | ||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/ghostbox_windows_x86_64.exe GhostBox.go # Windows 64bit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters