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
 | 
			
		||||
* ✅ Supports **private Git repositories** using `.netrc`-based auth
 | 
			
		||||
* ✅ 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`
 | 
			
		||||
* ✅ 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
 | 
			
		||||
docker run --rm \
 | 
			
		||||
  -e GIT_REPO=https://github.com/youruser/your-go-app.git \
 | 
			
		||||
  -e GIT_USERNAME=yourusername \
 | 
			
		||||
  -e GIT_TOKEN=yourtoken \
 | 
			
		||||
  -e GIT_REPO=https://git.tordarus.net/tordarus/hello-world.git \
 | 
			
		||||
  -e GIT_REF=main \
 | 
			
		||||
  tordarus/gorunner:latest
 | 
			
		||||
```
 | 
			
		||||
````
 | 
			
		||||
 | 
			
		||||
### 🐳 Docker Compose
 | 
			
		||||
 | 
			
		||||
@ -38,11 +38,12 @@ services:
 | 
			
		||||
  gorunner:
 | 
			
		||||
    image: tordarus/gorunner:latest
 | 
			
		||||
    environment:
 | 
			
		||||
      GIT_REPO: https://github.com/youruser/your-go-app.git
 | 
			
		||||
      GIT_USERNAME: yourusername   # Optional for public repos
 | 
			
		||||
      GIT_TOKEN: yourtoken         # Optional for public repos
 | 
			
		||||
      APP_PATH: .                  # Optional
 | 
			
		||||
      PACKAGES: curl               # Optional
 | 
			
		||||
      GIT_REPO: https://git.tordarus.net/tordarus/hello-world.git
 | 
			
		||||
      GIT_REF: main                # Optional – specify branch, tag, or commit
 | 
			
		||||
      GIT_USERNAME: yourusername  # Optional for public repos
 | 
			
		||||
      GIT_TOKEN: yourtoken        # Optional for public repos
 | 
			
		||||
      APP_PATH: .                 # Optional – subdir of Go app
 | 
			
		||||
      PACKAGES: curl              # Optional – comma-separated apk packages
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Then run it with:
 | 
			
		||||
@ -55,13 +56,14 @@ docker compose up
 | 
			
		||||
 | 
			
		||||
## 🔧 Environment Variables
 | 
			
		||||
 | 
			
		||||
| Variable       | Required | Description                                                             |
 | 
			
		||||
| -------------- | -------- | ----------------------------------------------------------------------- |
 | 
			
		||||
| `GIT_REPO`     | ✅ Yes    | The HTTPS Git URL of your Go project                                    |
 | 
			
		||||
| `GIT_USERNAME` | Optional | Your Git username (required for private repos)                          |
 | 
			
		||||
| `GIT_TOKEN`    | Optional | A personal access token or password (required for private repos)        |
 | 
			
		||||
| `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 |
 | 
			
		||||
| Variable       | Required | Description                                                              |
 | 
			
		||||
| -------------- | -------- | ------------------------------------------------------------------------ |
 | 
			
		||||
| `GIT_REPO`     | ✅ Yes    | The HTTPS Git URL of your Go project                                     |
 | 
			
		||||
| `GIT_REF`      | Optional | Branch name, tag, or commit hash to checkout after clone (default: HEAD) |
 | 
			
		||||
| `GIT_USERNAME` | Optional | Your Git username (required for private repos)                           |
 | 
			
		||||
| `GIT_TOKEN`    | Optional | A personal access token or password (required for private repos)         |
 | 
			
		||||
| `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
 | 
			
		||||
 | 
			
		||||
MIT License – feel free to modify and use.
 | 
			
		||||
MIT License – feel free to modify and use.
 | 
			
		||||
@ -30,7 +30,6 @@ password $GIT_TOKEN
 | 
			
		||||
EOF
 | 
			
		||||
  chmod 600 ~/.netrc
 | 
			
		||||
 | 
			
		||||
  # Prevent Git from prompting and force it to use .netrc
 | 
			
		||||
  export GIT_ASKPASS=true
 | 
			
		||||
  export GIT_TERMINAL_PROMPT=0
 | 
			
		||||
fi
 | 
			
		||||
@ -41,7 +40,16 @@ rm -rf /app/repo
 | 
			
		||||
echo "[CLONE] Cloning repository: $GIT_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..."
 | 
			
		||||
go build -o /app/app .
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user