Skip to content

Commit

Permalink
chore: update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
fioncat committed Jan 24, 2025
1 parent aa59c05 commit e198b39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM ${BUILD_IMAGE} AS builder
WORKDIR /usr/src/csync
COPY . .

RUN cargo build --release --locked
RUN cargo build --release --locked --no-default-features
RUN mv ./target/release/csync /usr/local/cargo/bin/csync

# Use BASE_IMAGE for the final stage
Expand Down
51 changes: 14 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
WHAT ?= debug
CARGO_CMD ?= cargo
DOCKER_CMD ?= docker
CARGO_TARGET ?=
BUILD_IMAGE ?= rust:latest
BASE_IMAGE ?= debian:latest
TARGET ?= fioncat/csync:latest
IMAGE ?= fioncat/csync:latest

.PHONY: all
all: build
all:
cargo build

.PHONY: build
build:
ifeq ($(WHAT),release)
$(if $(CARGO_TARGET), \
$(CARGO_CMD) build --release --target $(CARGO_TARGET), \
$(CARGO_CMD) build --release)
else ifeq ($(WHAT),docker)
.PHONY: release
release:
cargo build --release --locked

.PHONY: minimal
minimal:
cargo build --release --locked --no-default-features

.PHONY: docker
docker:
$(DOCKER_CMD) build \
--build-arg BUILD_IMAGE=$(BUILD_IMAGE) \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
-t $(TARGET) .
else
$(if $(CARGO_TARGET), \
$(CARGO_CMD) build --target $(CARGO_TARGET), \
$(CARGO_CMD) build)
endif
-t $(IMAGE) .

.PHONY: install
install:
Expand All @@ -33,22 +29,3 @@ install:
.PHONY: clean
clean:
$(CARGO_CMD) clean

.PHONY: help
help:
@echo "Usage:"
@echo " make [WHAT=<target>] [options]"
@echo ""
@echo "Targets:"
@echo " debug - Build debug version (default)"
@echo " release - Build release version"
@echo " docker - Build docker image"
@echo " install - Install using cargo install"
@echo ""
@echo "Options:"
@echo " CARGO_CMD - Specify cargo command (default: cargo)"
@echo " CARGO_TARGET - Specify build target"
@echo " DOCKER_CMD - Specify docker command (default: docker)"
@echo " BUILD_IMAGE - Specify builder image (default: rust:alpine)"
@echo " BASE_IMAGE - Specify base image (default: alpine:latest)"
@echo " TARGET - Specify docker image tag (default: fioncat/csync:latest)"

0 comments on commit e198b39

Please sign in to comment.