Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ integrated_examples/*/.git
integrated_examples/*/.coasts
integrated_examples/*/node_modules
.dindind-image-cache/
.dev/
29 changes: 29 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"coast-daemon",
"coast-cli",
"coast-update",
"coast-service",
"integration-tests",
]
resolver = "2"
Expand Down
72 changes: 72 additions & 0 deletions Dockerfile.coast-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM rust:1.94-bookworm AS builder

WORKDIR /build

# Copy workspace manifests first for layer caching.
COPY Cargo.toml Cargo.lock ./
COPY coast-core/Cargo.toml coast-core/Cargo.toml
COPY coast-i18n/Cargo.toml coast-i18n/Cargo.toml
COPY coast-secrets/Cargo.toml coast-secrets/Cargo.toml
COPY coast-docker/Cargo.toml coast-docker/Cargo.toml
COPY coast-daemon/Cargo.toml coast-daemon/Cargo.toml
COPY coast-cli/Cargo.toml coast-cli/Cargo.toml
COPY coast-update/Cargo.toml coast-update/Cargo.toml
COPY coast-service/Cargo.toml coast-service/Cargo.toml
COPY integration-tests/Cargo.toml integration-tests/Cargo.toml

# Stub out all crate lib/main files so cargo can resolve the dependency graph
# and cache downloaded + compiled dependencies.
RUN mkdir -p coast-core/src && echo "" > coast-core/src/lib.rs && \
mkdir -p coast-i18n/src && echo "" > coast-i18n/src/lib.rs && \
mkdir -p coast-secrets/src && echo "" > coast-secrets/src/lib.rs && \
mkdir -p coast-docker/src && echo "" > coast-docker/src/lib.rs && \
mkdir -p coast-daemon/src && echo "fn main() {}" > coast-daemon/src/main.rs && echo "" > coast-daemon/src/lib.rs && \
mkdir -p coast-daemon/src/bin && echo "fn main() {}" > coast-daemon/src/bin/coastd-dev.rs && \
mkdir -p coast-cli/src && echo "fn main() {}" > coast-cli/src/main.rs && echo "" > coast-cli/src/lib.rs && \
mkdir -p coast-cli/src/bin && echo "fn main() {}" > coast-cli/src/bin/coast-dev.rs && \
mkdir -p coast-update/src && echo "" > coast-update/src/lib.rs && \
mkdir -p coast-service/src && echo "fn main() {}" > coast-service/src/main.rs && echo "" > coast-service/src/lib.rs && \
mkdir -p integration-tests/src && echo "" > integration-tests/src/lib.rs

# Pre-build dependencies (cached unless Cargo.toml/Cargo.lock change).
RUN cargo build --release -p coast-service 2>/dev/null || true

# Copy real source and build.
COPY coast-core/ coast-core/
COPY coast-i18n/ coast-i18n/
COPY coast-secrets/ coast-secrets/
COPY coast-docker/ coast-docker/
COPY coast-service/ coast-service/

# Touch source files so cargo knows they changed.
RUN find coast-core coast-i18n coast-secrets coast-docker coast-service \
-name "*.rs" -exec touch {} +

RUN cargo build --release -p coast-service

# --- Runtime ---
FROM debian:bookworm-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
docker.io \
rsync \
openssh-client && \
rm -rf /var/lib/apt/lists/*

RUN ARCH=$(dpkg --print-architecture) && \
curl -fsSL "https://github.com/mutagen-io/mutagen/releases/download/v0.18.1/mutagen_linux_${ARCH}_v0.18.1.tar.gz" \
| tar xz -C /usr/local/bin && chmod +x /usr/local/bin/mutagen

COPY --from=builder /build/target/release/coast-service /usr/local/bin/coast-service

ENV COAST_SERVICE_HOME=/data
ENV COAST_SERVICE_PORT=31420

EXPOSE 31420

VOLUME ["/data"]

ENTRYPOINT ["coast-service"]
36 changes: 36 additions & 0 deletions Dockerfile.coast-service.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM rust:1-bookworm

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
docker.io \
iptables \
rsync \
openssh-server && \
rm -rf /var/lib/apt/lists/*

# Install mutagen for continuous file sync.
RUN ARCH=$(dpkg --print-architecture) && \
curl -fsSL "https://github.com/mutagen-io/mutagen/releases/download/v0.18.1/mutagen_linux_${ARCH}_v0.18.1.tar.gz" \
| tar xz -C /usr/local/bin && chmod +x /usr/local/bin/mutagen

# Generate sshd host keys and prepare runtime dirs.
RUN ssh-keygen -A && mkdir -p /run/sshd /root/.ssh

RUN cargo install cargo-watch

WORKDIR /workspace

COPY dev/coast-service-entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENV COAST_SERVICE_HOME=/data
ENV COAST_SERVICE_PORT=31420

EXPOSE 31420 22

VOLUME ["/data", "/var/lib/docker"]

ENTRYPOINT ["entrypoint.sh"]
35 changes: 34 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export

.PHONY: lint fix test coverage coverage-text coverage-lcov check zip-projects unpack-projects merge-zip watch \
docs-version docs-status translate translate-all doc-search doc-search-all \
prune run-dind-integration
prune coast-service-keygen coast-service-dev-build coast-service-dev run-dind-integration

# Check formatting and run clippy. Matches CI: -D warnings promotes all
# warnings to errors so local lint catches what CI catches.
Expand Down Expand Up @@ -140,6 +140,39 @@ endif
@echo "Done. Run 'df -h /Users' to check free space."
@echo "Note: Docker Desktop may need a restart to compact its disk image."

# --- coast-service ---

# Generate SSH keys for dev testing. Idempotent.
coast-service-keygen:
@mkdir -p .dev/ssh
@if [ ! -f .dev/ssh/coast_dev_key ]; then \
ssh-keygen -t ed25519 -f .dev/ssh/coast_dev_key -N "" -q; \
echo "Generated .dev/ssh/coast_dev_key"; \
else \
echo "SSH keys already exist in .dev/ssh/"; \
fi

# Build the coast-service dev image.
coast-service-dev-build:
docker build -t coast-service-dev -f Dockerfile.coast-service.dev .

# Run coast-service in dev mode with DinD + SSH. Ctrl-C to stop.
# Bind-mounts source, cargo-watch auto-rebuilds on changes.
# SSH on port 2222, coast-service HTTP on port 31420.
coast-service-dev: coast-service-keygen coast-service-dev-build
docker run --rm -it \
--privileged \
--name coast-service-dev \
-p 31420:31420 \
-p 2222:22 \
-v $(CURDIR):/workspace \
-v $(CURDIR)/.dev/ssh/coast_dev_key.pub:/root/.ssh/authorized_keys:ro \
-v coast-service-dev-docker:/var/lib/docker \
-v coast-service-data:/data \
-v coast-service-dev-cargo:/usr/local/cargo/registry \
-v coast-service-dev-target:/workspace/target \
coast-service-dev

# --- DinD integration tests ---

# Run integration tests inside a DinD container.
Expand Down
1 change: 1 addition & 0 deletions coast-cli/src/commands/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub async fn execute(args: &AssignArgs, project: &str) -> Result<()> {
commit_sha,
explain: args.explain,
force_sync: args.force_sync,
service_actions: Default::default(),
});

if args.explain {
Expand Down
5 changes: 5 additions & 0 deletions coast-cli/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct BuildArgs {
#[arg(long)]
pub refresh: bool,

/// Which remote to build on (only used with --type remote).
#[arg(long)]
pub remote: Option<String>,

/// Suppress all progress output; only print the final summary (or errors).
#[arg(short = 's', long)]
pub silent: bool,
Expand Down Expand Up @@ -387,6 +391,7 @@ pub async fn execute(args: &BuildArgs) -> Result<()> {
let request = Request::Build(BuildRequest {
coastfile_path,
refresh: args.refresh,
remote: args.remote.clone(),
});

let verbosity = if args.silent {
Expand Down
Loading