mirror of
https://github.com/alexhopeoconnor/bom-local-service.git
synced 2026-10-04 03:28:11 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5aee5be82 | ||
|
|
319d397b41 |
@@ -21,6 +21,12 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
@@ -40,6 +46,7 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
+3
-6
@@ -34,12 +34,9 @@ COPY --from=publish /app/publish .
|
||||
# Create cache directory for screenshots
|
||||
RUN mkdir -p /app/cache && chmod 777 /app/cache
|
||||
|
||||
# Create startup script to run Xvfb and then the app
|
||||
RUN echo '#!/bin/bash\n\
|
||||
Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &\n\
|
||||
export DISPLAY=:99\n\
|
||||
exec dotnet BomLocalService.dll' > /app/start.sh && \
|
||||
chmod +x /app/start.sh
|
||||
# Copy startup script
|
||||
COPY scripts/docker-start.sh /app/start.sh
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
# OCI labels for GitHub Container Registry metadata
|
||||
LABEL org.opencontainers.image.source="https://github.com/alexhopeoconnor/bom-local-service"
|
||||
|
||||
@@ -46,7 +46,27 @@ Built on ASP.NET Core 9.0, the service uses a service-oriented architecture with
|
||||
- **CacheController**: REST endpoints for cache management operations (`/api/cache/{suburb}/{state}`)
|
||||
- **RadarTestController**: MVC controller serving the demo SPA at `/radar/{suburb}/{state}`
|
||||
|
||||
## Building with Docker
|
||||
## Installation
|
||||
|
||||
### Docker Image
|
||||
|
||||
Pre-built Docker images are available on GitHub Container Registry:
|
||||
|
||||
**Image:** `ghcr.io/alexhopeoconnor/bom-local-service`
|
||||
|
||||
**Multi-architecture support:** Images are built for both `linux/amd64` and `linux/arm64` platforms
|
||||
|
||||
**Pull the latest version:**
|
||||
```bash
|
||||
docker pull ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
**Pull a specific version:**
|
||||
```bash
|
||||
docker pull ghcr.io/alexhopeoconnor/bom-local-service:v0.0.1
|
||||
```
|
||||
|
||||
See all available versions on the [releases page](https://github.com/alexhopeoconnor/bom-local-service/releases).
|
||||
|
||||
### Prerequisites
|
||||
|
||||
@@ -55,9 +75,34 @@ Built on ASP.NET Core 9.0, the service uses a service-oriented architecture with
|
||||
|
||||
### Quick Start
|
||||
|
||||
#### Option 1: Using Pre-built Docker Image (Recommended)
|
||||
|
||||
Pull the latest image from GitHub Container Registry:
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
Then run the container:
|
||||
```bash
|
||||
docker run -d \
|
||||
--name bom-local-service \
|
||||
-p 8082:8080 \
|
||||
-v $(pwd)/cache:/app/cache \
|
||||
--shm-size=1gb \
|
||||
--ipc=host \
|
||||
ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
**Available tags:**
|
||||
- `latest` - Latest release
|
||||
- `v0.0.1` - Specific version (see [releases](https://github.com/alexhopeoconnor/bom-local-service/releases) for all versions)
|
||||
|
||||
#### Option 2: Build from Source
|
||||
|
||||
1. **Clone the repository**:
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
git clone https://github.com/alexhopeoconnor/bom-local-service.git
|
||||
cd bom-local-service
|
||||
```
|
||||
|
||||
@@ -86,14 +131,32 @@ Built on ASP.NET Core 9.0, the service uses a service-oriented architecture with
|
||||
|
||||
### Using Docker Compose
|
||||
|
||||
The included `docker-compose.yml` provides a convenient way to run the service with all configuration options:
|
||||
The included `docker-compose.yml` provides a convenient way to run the service with all configuration options.
|
||||
|
||||
**Using pre-built image (recommended):**
|
||||
|
||||
Update `docker-compose.yml` to use the GitHub Container Registry image:
|
||||
```yaml
|
||||
services:
|
||||
bom-local-service:
|
||||
image: ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
# Remove or comment out the 'build:' section
|
||||
```
|
||||
|
||||
Then run:
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
**Building from source:**
|
||||
|
||||
If you want to build locally, keep the `build:` section in `docker-compose.yml` and run:
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
This will:
|
||||
- Build the image if it doesn't exist
|
||||
- Pull/build the image as configured
|
||||
- Start the service on port 8082 (configurable via `HOST_PORT`)
|
||||
- Mount the `./cache` directory for persistent storage
|
||||
- Apply all environment variable configurations
|
||||
@@ -180,7 +243,7 @@ docker run -d \
|
||||
-e CACHEEXPIRATIONMINUTES=15 \
|
||||
--shm-size=1gb \
|
||||
--ipc=host \
|
||||
bom-local-service
|
||||
ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
#### Custom Cache Directory
|
||||
@@ -193,7 +256,7 @@ docker run -d \
|
||||
-e CACHEDIRECTORY=/app/cache \
|
||||
--shm-size=1gb \
|
||||
--ipc=host \
|
||||
bom-local-service
|
||||
ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
#### Development Mode with Debug
|
||||
@@ -208,7 +271,7 @@ docker run -d \
|
||||
-e DEBUG__WAITMS=5000 \
|
||||
--shm-size=1gb \
|
||||
--ipc=host \
|
||||
bom-local-service
|
||||
ghcr.io/alexhopeoconnor/bom-local-service:latest
|
||||
```
|
||||
|
||||
#### Using docker-compose with Custom Settings
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Function to start Xvfb
|
||||
start_xvfb() {
|
||||
if ! pgrep -f "Xvfb :99" > /dev/null; then
|
||||
echo "Starting Xvfb on display :99..."
|
||||
Xvfb :99 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
|
||||
sleep 1
|
||||
if ! pgrep -f "Xvfb :99" > /dev/null; then
|
||||
echo "ERROR: Xvfb failed to start" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Xvfb started successfully"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to monitor and restart Xvfb if it dies (runs as background process)
|
||||
monitor_xvfb() {
|
||||
# Monitor while PID 1 (dotnet after exec) is still running
|
||||
while kill -0 1 2>/dev/null; do
|
||||
sleep 5
|
||||
if ! pgrep -f "Xvfb :99" > /dev/null; then
|
||||
echo "WARNING: Xvfb process not found, restarting..." >&2
|
||||
start_xvfb || true
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
echo "Shutting down Xvfb..."
|
||||
pkill -f "Xvfb :99" || true
|
||||
}
|
||||
|
||||
# Set up signal handlers for cleanup
|
||||
trap cleanup SIGTERM SIGINT EXIT
|
||||
|
||||
# Start Xvfb
|
||||
start_xvfb || exit 1
|
||||
|
||||
# Export DISPLAY
|
||||
export DISPLAY=:99
|
||||
|
||||
# Start monitoring in background (will check if PID 1 is still running)
|
||||
monitor_xvfb &
|
||||
|
||||
# Start the .NET application (replaces shell as PID 1)
|
||||
exec dotnet BomLocalService.dll
|
||||
Reference in New Issue
Block a user