Skip to content

Commit 59facad

Browse files
authored
Merge pull request #7 from codcod/6-build-error-while-creating-docker-image
fix: docker build errors
2 parents c545d42 + c3a5d13 commit 59facad

File tree

3 files changed

+88
-44
lines changed

3 files changed

+88
-44
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ docs/
1515

1616
# Build artifacts
1717
target/
18-
Cargo.lock
1918

2019
# Local configs and data
2120
config.yaml

Dockerfile

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
11
# Build stage
2-
FROM rust:1.88-alpine3.22 as builder
2+
FROM rust:1.90-alpine3.22 AS builder
33

44
WORKDIR /app
55

6-
# Install dependencies
7-
RUN apt-get update && apt-get install -y \
8-
pkg-config \
9-
libssl-dev \
6+
# Install build dependencies for Alpine
7+
RUN apk add --no-cache \
8+
musl-dev \
9+
pkgconfig \
10+
openssl-dev \
11+
openssl-libs-static \
1012
git \
11-
&& rm -rf /var/lib/apt/lists/*
13+
gcc
1214

13-
# Copy source code
14-
COPY . .
15+
# Copy dependency files first for better caching
16+
COPY Cargo.toml Cargo.lock ./
1517

16-
# Build the application
17-
RUN cargo build --release
18+
# Create dummy source to build dependencies
19+
RUN mkdir src && echo "fn main() {}" > src/main.rs && \
20+
cargo build --release && \
21+
rm -rf src
1822

19-
# Runtime stage
20-
FROM debian:12.8-slim
23+
# Copy actual source code
24+
COPY src ./src
2125

22-
# Install runtime dependencies
23-
RUN apt-get update && apt-get install -y \
24-
git \
25-
ca-certificates \
26-
&& rm -rf /var/lib/apt/lists/*
27-
28-
# Create a non-root user
29-
RUN useradd -r -s /bin/false repos
26+
# Build the application with optimizations (already musl in Alpine)
27+
RUN cargo build --release && \
28+
strip target/release/repos
3029

31-
# Copy the binary from builder stage
32-
COPY --from=builder /app/target/release/repos /usr/local/bin/repos
30+
# Runtime stage - use scratch for minimal size
31+
FROM scratch
3332

34-
# Set the user
35-
USER repos
33+
# Copy CA certificates for HTTPS
34+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
3635

37-
# Set the working directory
38-
WORKDIR /workspace
36+
# Copy the statically linked binary
37+
COPY --from=builder /app/target/release/repos /repos
3938

4039
# Set the entrypoint
41-
ENTRYPOINT ["repos"]
40+
ENTRYPOINT ["/repos"]
4241
CMD ["--help"]

README.md

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ Repos is a CLI tool to manage multiple GitHub repositories - clone them, run
44
commands across all repositories, create pull requests, and more—all with
55
colored output and comprehensive logging.
66

7+
## Table of contents
8+
9+
- [Features](#features)
10+
- [Installation](#installation)
11+
- [Configuration](#configuration)
12+
- [Usage](#usage)
13+
- [Repository management](#repository-management)
14+
- [Running commands](#running-commands)
15+
- [Creating Pull Requests](#creating-pull-requests)
16+
- [Docker image](#docker-image)
17+
- [Contributing](#contributing)
18+
- [License](#license)
19+
720
## Features
821

922
- **Multi-repository management**: Clone and manage multiple repositories from a
@@ -20,7 +33,7 @@ repositories
2033

2134
## Installation
2235

23-
### From Source
36+
### From source
2437

2538
```bash
2639
git clone https://github.com/codcod/repos.git
@@ -77,7 +90,7 @@ git clone http://github.com/example/project2.git
7790
repos init
7891
```
7992

80-
## Typical Session
93+
## Typical session
8194

8295
Once you have a configuration file in place, an example session can look like the following:
8396

@@ -100,7 +113,7 @@ repos pr --title "Update dependencies" --body "Update Cargo.lock files"
100113

101114
## Usage
102115

103-
### Repository Management
116+
### Repository management
104117

105118
To configure, clone and remove repositories:
106119

@@ -136,7 +149,7 @@ repos rm -t rust
136149
repos rm -p
137150
```
138151

139-
### Running Commands
152+
### Running commands
140153

141154
To run arbitrary commands in repositories:
142155

@@ -154,7 +167,7 @@ repos run -p "cargo test"
154167
repos run -l custom/logs "make build"
155168
```
156169

157-
#### Example Commands
170+
#### Example commands
158171

159172
Example commands to run with `repos run ""`:
160173

@@ -180,25 +193,38 @@ git log --all --author='$(id -un)' --since='1 month ago' --pretty=format:'%h %an
180193

181194
### Creating Pull Requests
182195

183-
To submit changes made in the cloned repositories:
196+
Set GITHUB_TOKEN in the environment (or pass via `--token`), then:
184197

185198
```bash
186-
export GITHUB_TOKEN=your_github_token
199+
# Basic: create PRs for repos with changes
200+
export GITHUB_TOKEN=your_token
201+
repos pr --title "Update deps" --body "Update Cargo.lock files"
187202

188-
# Create PRs for repositories with changes
189-
repos pr --title "My changes" --body "Description of changes"
203+
# Use a specific branch name and base branch
204+
repos pr --branch feature/foo --base develop --title "My change"
190205

191-
# Create PRs with specific branch name
192-
repos pr --branch feature/my-changes --title "My changes"
206+
# Commit message override and make draft PRs
207+
repos pr --commit-msg "chore: update deps" --draft
193208

194-
# Create draft pull requests
195-
repos pr --draft
209+
# Only create PR (don't push/commit) — useful for dry-run workflows
210+
repos pr --create-only
196211

197-
# Create PRs for specific repositories
198-
repos pr -t backend
212+
# Filter repositories and run in parallel
213+
repos pr -t backend -p --title "Backend changes"
199214
```
200215

201-
## Command Reference
216+
Available PR options (CLI flags)
217+
218+
- --title TITLE (required for PR creation)
219+
- --body BODY
220+
- --branch / --branch-name NAME (optional)
221+
- --base BRANCH (optional; defaults to repo default branch — will detect it)
222+
- --commit-msg MSG (optional)
223+
- --draft (optional)
224+
- --create-only (optional)
225+
- --token TOKEN (optional; otherwise uses GITHUB_TOKEN env var)
226+
227+
## Command reference
202228

203229
```text
204230
A tool to manage multiple GitHub repositories
@@ -233,6 +259,26 @@ Options:
233259
- `walkdir` - Directory traversal
234260
- `uuid` - Unique ID generation
235261

262+
## Docker image
263+
264+
Quick usage:
265+
266+
```bash
267+
# build image (from repo root)
268+
docker build -t repos:latest .
269+
270+
# run help
271+
docker run --rm repos:latest
272+
273+
# run PR command (ensure token passed)
274+
docker run --rm
275+
-e GITHUB_TOKEN="$GITHUB_TOKEN" \
276+
repos:latest pr --title "fix: update config" --body "Detailed description"
277+
```
278+
279+
Tip: mount host workspace if operations need local files:
280+
`docker run --rm -v "$(pwd):/work" -w /work -e GITHUB_TOKEN="$GITHUB_TOKEN" repos:latest run "ls -la"`
281+
236282
## Contributing
237283

238284
1. Fork the repository

0 commit comments

Comments
 (0)