Skip to content

Commit 743f156

Browse files
authored
Merge pull request #63 from openSVM/copilot/fix-62
Add Docker support and CI workflow for GitHub Container Registry
2 parents 0565d5c + 333e711 commit 743f156

File tree

4 files changed

+161
-0
lines changed

4 files changed

+161
-0
lines changed

.dockerignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
target/
2+
.git/
3+
.github/
4+
Dockerfile*
5+
docker-compose*
6+
.dockerignore
7+
README.md
8+
.gitignore
9+
*.md
10+
.env*
11+
.vscode/
12+
.idea/
13+
*.tmp
14+
*.log
15+
tests/
16+
examples/
17+
*.yml
18+
*.yaml
19+
.cline_rules
20+
.devcontainer/
21+
CNAME
22+
index.html
23+
*.sh
24+
*.ps1
25+
*.py
26+
INSTALLATION.md
27+
LICENSE
28+
Makefile*
29+
pre-commit
30+
*.toml
31+
!Cargo.toml
32+
!rust-toolchain.toml
33+
validate_full_history.sh

.github/workflows/docker.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Docker Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Log in to Container Registry
26+
if: github.event_name != 'pull_request'
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=semver,pattern={{version}}
42+
type=semver,pattern={{major}}.{{minor}}
43+
type=semver,pattern={{major}}
44+
type=sha
45+
46+
- name: Build and push Docker image
47+
uses: docker/build-push-action@v5
48+
with:
49+
context: .
50+
push: ${{ github.event_name != 'pull_request' }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
54+
- name: Test Docker image
55+
if: github.event_name != 'pull_request'
56+
run: |
57+
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} --version

Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Multi-stage build for osvm CLI
2+
FROM rust:1.87-slim AS builder
3+
4+
# Install dependencies for building
5+
RUN apt-get update && apt-get install -y \
6+
pkg-config \
7+
libssl-dev \
8+
libudev-dev \
9+
perl \
10+
make \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# Set working directory
14+
WORKDIR /app
15+
16+
# Copy dependency files first for better caching
17+
COPY Cargo.toml Cargo.lock ./
18+
COPY rust-toolchain.toml ./
19+
20+
# Copy vendor directory if it exists
21+
COPY vendor/ ./vendor/
22+
23+
# Copy source code
24+
COPY src/ ./src/
25+
26+
# Build the application
27+
RUN cargo build --release
28+
29+
# Runtime image
30+
FROM debian:bookworm-slim
31+
32+
# Install runtime dependencies
33+
RUN apt-get update && apt-get install -y \
34+
ca-certificates \
35+
libudev1 \
36+
libssl3 \
37+
&& rm -rf /var/lib/apt/lists/*
38+
39+
# Create non-root user
40+
RUN useradd -m -u 1000 osvm
41+
42+
# Copy the binary from builder stage
43+
COPY --from=builder /app/target/release/osvm /usr/local/bin/osvm
44+
45+
# Make it executable
46+
RUN chmod +x /usr/local/bin/osvm
47+
48+
# Switch to non-root user
49+
USER osvm
50+
51+
# Set the entrypoint
52+
ENTRYPOINT ["/usr/local/bin/osvm"]
53+
CMD ["--help"]

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,24 @@ curl -sSf https://raw.githubusercontent.com/opensvm/osvm-cli/main/install.sh | s
107107
powershell -Command "Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/opensvm/osvm-cli/main/install.ps1' -OutFile 'install.ps1'; .\install.ps1"
108108
```
109109

110+
### Docker
111+
112+
Run OSVM CLI in a Docker container without installing it locally:
113+
114+
```bash
115+
# Pull the latest image
116+
docker pull ghcr.io/opensvm/osvm-cli:latest
117+
118+
# Run with version check
119+
docker run --rm ghcr.io/opensvm/osvm-cli:latest --version
120+
121+
# Run with interactive mode (mount current directory)
122+
docker run --rm -it -v $(pwd):/workspace ghcr.io/opensvm/osvm-cli:latest
123+
124+
# Use as an alias
125+
alias osvm='docker run --rm -it -v $(pwd):/workspace ghcr.io/opensvm/osvm-cli:latest'
126+
```
127+
110128
## 🌟 Key Features
111129

112130
- **SVM Management**: List and inspect Solana Virtual Machines

0 commit comments

Comments
 (0)