added GIT_REF
This commit is contained in:
36
README.md
36
README.md
@ -11,6 +11,7 @@ This Docker image is designed to **download**, **compile**, and **run** a Go pro
|
|||||||
* ✅ Clones a Go repository at runtime
|
* ✅ Clones a Go repository at runtime
|
||||||
* ✅ Supports **private Git repositories** using `.netrc`-based auth
|
* ✅ Supports **private Git repositories** using `.netrc`-based auth
|
||||||
* ✅ Builds and runs your Go application
|
* ✅ Builds and runs your Go application
|
||||||
|
* ✅ Supports checking out a specific **branch, tag, or commit** via `GIT_REF`
|
||||||
* ✅ Multi-architecture: `linux/amd64`, `linux/arm64`, `linux/arm/v7`
|
* ✅ Multi-architecture: `linux/amd64`, `linux/arm64`, `linux/arm/v7`
|
||||||
* ✅ Minimal and reproducible container setup with Alpine Linux
|
* ✅ Minimal and reproducible container setup with Alpine Linux
|
||||||
|
|
||||||
@ -22,11 +23,10 @@ This Docker image is designed to **download**, **compile**, and **run** a Go pro
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-e GIT_REPO=https://github.com/youruser/your-go-app.git \
|
-e GIT_REPO=https://git.tordarus.net/tordarus/hello-world.git \
|
||||||
-e GIT_USERNAME=yourusername \
|
-e GIT_REF=main \
|
||||||
-e GIT_TOKEN=yourtoken \
|
|
||||||
tordarus/gorunner:latest
|
tordarus/gorunner:latest
|
||||||
```
|
````
|
||||||
|
|
||||||
### 🐳 Docker Compose
|
### 🐳 Docker Compose
|
||||||
|
|
||||||
@ -38,11 +38,12 @@ services:
|
|||||||
gorunner:
|
gorunner:
|
||||||
image: tordarus/gorunner:latest
|
image: tordarus/gorunner:latest
|
||||||
environment:
|
environment:
|
||||||
GIT_REPO: https://github.com/youruser/your-go-app.git
|
GIT_REPO: https://git.tordarus.net/tordarus/hello-world.git
|
||||||
GIT_USERNAME: yourusername # Optional for public repos
|
GIT_REF: main # Optional – specify branch, tag, or commit
|
||||||
GIT_TOKEN: yourtoken # Optional for public repos
|
GIT_USERNAME: yourusername # Optional for public repos
|
||||||
APP_PATH: . # Optional
|
GIT_TOKEN: yourtoken # Optional for public repos
|
||||||
PACKAGES: curl # Optional
|
APP_PATH: . # Optional – subdir of Go app
|
||||||
|
PACKAGES: curl # Optional – comma-separated apk packages
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run it with:
|
Then run it with:
|
||||||
@ -55,13 +56,14 @@ docker compose up
|
|||||||
|
|
||||||
## 🔧 Environment Variables
|
## 🔧 Environment Variables
|
||||||
|
|
||||||
| Variable | Required | Description |
|
| Variable | Required | Description |
|
||||||
| -------------- | -------- | ----------------------------------------------------------------------- |
|
| -------------- | -------- | ------------------------------------------------------------------------ |
|
||||||
| `GIT_REPO` | ✅ Yes | The HTTPS Git URL of your Go project |
|
| `GIT_REPO` | ✅ Yes | The HTTPS Git URL of your Go project |
|
||||||
| `GIT_USERNAME` | Optional | Your Git username (required for private repos) |
|
| `GIT_REF` | Optional | Branch name, tag, or commit hash to checkout after clone (default: HEAD) |
|
||||||
| `GIT_TOKEN` | Optional | A personal access token or password (required for private repos) |
|
| `GIT_USERNAME` | Optional | Your Git username (required for private repos) |
|
||||||
| `APP_PATH` | Optional | Relative path to the Go module directory inside the repo (default: `.`) |
|
| `GIT_TOKEN` | Optional | A personal access token or password (required for private repos) |
|
||||||
| `PACKAGES` | Optional | Comma-separated list of packages to install with `apk` before execution |
|
| `APP_PATH` | Optional | Relative path to the Go module directory inside the repo (default: `.`) |
|
||||||
|
| `PACKAGES` | Optional | Comma-separated list of packages to install with `apk` before execution |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -84,4 +86,4 @@ Found a bug or have an idea for improvement?
|
|||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
MIT License – feel free to modify and use.
|
MIT License – feel free to modify and use.
|
@ -30,7 +30,6 @@ password $GIT_TOKEN
|
|||||||
EOF
|
EOF
|
||||||
chmod 600 ~/.netrc
|
chmod 600 ~/.netrc
|
||||||
|
|
||||||
# Prevent Git from prompting and force it to use .netrc
|
|
||||||
export GIT_ASKPASS=true
|
export GIT_ASKPASS=true
|
||||||
export GIT_TERMINAL_PROMPT=0
|
export GIT_TERMINAL_PROMPT=0
|
||||||
fi
|
fi
|
||||||
@ -41,7 +40,16 @@ rm -rf /app/repo
|
|||||||
echo "[CLONE] Cloning repository: $GIT_REPO"
|
echo "[CLONE] Cloning repository: $GIT_REPO"
|
||||||
git clone "$GIT_REPO" repo
|
git clone "$GIT_REPO" repo
|
||||||
|
|
||||||
cd repo/"${APP_PATH:-.}"
|
cd repo
|
||||||
|
|
||||||
|
# Checkout specific branch, tag, or commit if provided
|
||||||
|
if [ -n "$GIT_REF" ]; then
|
||||||
|
echo "[GIT] Checking out ref: $GIT_REF"
|
||||||
|
git fetch --all --tags
|
||||||
|
git checkout "$GIT_REF"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "${APP_PATH:-.}"
|
||||||
|
|
||||||
echo "[BUILD] Building..."
|
echo "[BUILD] Building..."
|
||||||
go build -o /app/app .
|
go build -o /app/app .
|
||||||
|
Reference in New Issue
Block a user