Skip to content

Commit 1450bc0

Browse files
committed
initial commit
1 parent 7668234 commit 1450bc0

File tree

5 files changed

+257
-1
lines changed

5 files changed

+257
-1
lines changed

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# CI/CD
7+
.github
8+
9+
# Documentation
10+
README.md
11+
*.md
12+
13+
# IDE
14+
.vscode
15+
.idea
16+
*.swp
17+
*.swo
18+
*~
19+
20+
# OS
21+
.DS_Store
22+
Thumbs.db
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build, Test, and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
workflow_dispatch:
13+
14+
env:
15+
REGISTRY: docker.io
16+
IMAGE_NAME: brianlball/urbanopt-cloud
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
packages: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Read VERSION file
30+
run: |
31+
VERSION=$(head -1 VERSION | tr -d '[:space:]')
32+
if [[ ! "$VERSION" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
33+
echo "Error: VERSION file must contain a valid semantic version (e.g., 1.1.0)"
34+
exit 1
35+
fi
36+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
37+
echo "Using version: ${VERSION}"
38+
39+
- name: Set up Docker Buildx
40+
uses: docker/setup-buildx-action@v3
41+
42+
- name: Log in to Docker Hub
43+
if: github.event_name != 'pull_request'
44+
uses: docker/login-action@v3
45+
with:
46+
username: ${{ secrets.DOCKER_USERNAME }}
47+
password: ${{ secrets.DOCKER_PASSWORD }}
48+
49+
- name: Extract metadata (tags, labels) for Docker
50+
id: meta
51+
uses: docker/metadata-action@v5
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=raw,value=latest,enable={{is_default_branch}}
56+
type=raw,value=${{ env.VERSION }},enable={{is_default_branch}}
57+
58+
- name: Build Docker image
59+
uses: docker/build-push-action@v5
60+
with:
61+
context: .
62+
load: true
63+
tags: urbanopt-cloud:${{ env.VERSION }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
67+
- name: Test Docker container
68+
run: |
69+
echo "Testing Docker container..."
70+
docker run --rm urbanopt-cloud:${{ env.VERSION }} uo --version
71+
echo "Container test passed!"
72+
73+
- name: Build and push Docker image
74+
if: github.event_name != 'pull_request'
75+
uses: docker/build-push-action@v5
76+
with:
77+
context: .
78+
push: true
79+
tags: ${{ steps.meta.outputs.tags }}
80+
labels: ${{ steps.meta.outputs.labels }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# URBANopt CLI 1.1.0 (installer-based) on Ubuntu 22.04
2+
FROM ubuntu:22.04
3+
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
6+
# Set to either: x86_64 or arm64
7+
ARG UO_ARCH=x86_64
8+
9+
# URBANopt CLI 1.1.0 release details
10+
ARG UO_VERSION=1.1.0
11+
ARG UO_BUILD=117bfcec1a
12+
13+
# Runtime deps (OpenStudio/E+ often need X/GL libs even headless)
14+
RUN apt-get update && apt-get install -y --no-install-recommends \
15+
ca-certificates curl bash unzip zip git \
16+
libx11-6 libgl1 libxt6 libxext6 libxrender1 libxi6 \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
# Download + install URBANopt CLI .deb
20+
RUN set -eux; \
21+
DEB="URBANoptCLI-${UO_VERSION}.${UO_BUILD}-Ubuntu-22.04-${UO_ARCH}.deb"; \
22+
URL="https://github.com/urbanopt/urbanopt-cli/releases/download/v${UO_VERSION}/${DEB}"; \
23+
echo "Downloading ${URL}"; \
24+
curl -fL "${URL}" -o /tmp/urbanopt.deb; \
25+
apt-get update; \
26+
apt-get install -y /tmp/urbanopt.deb; \
27+
rm -f /tmp/urbanopt.deb; \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
# Generate the env file (~/.env_uo.sh) in the image
31+
RUN /usr/local/urbanopt-cli-${UO_VERSION}/setup-env.sh
32+
33+
# Provide Ruby globally (helps non-shell invocations that need /usr/bin/env ruby)
34+
RUN ln -sf /usr/local/urbanopt-cli-${UO_VERSION}/ruby/bin/ruby /usr/local/bin/ruby
35+
# symlink ruby
36+
RUN ln -sf /usr/local/urbanopt-cli-${UO_VERSION}/ruby/bin/ruby /usr/local/urbanopt-cli-${UO_VERSION}/gems/ruby/3.2.0/bin/ruby
37+
38+
39+
# Robust `uo` wrapper: always sources ~/.env_uo.sh then runs the real uo
40+
RUN set -eux; \
41+
UO_ROOT="/usr/local/urbanopt-cli-${UO_VERSION}"; \
42+
UO_REAL="${UO_ROOT}/gems/ruby/3.2.0/bin/uo"; \
43+
{ \
44+
printf '%s\n' '#!/usr/bin/env bash'; \
45+
printf '%s\n' 'set -euo pipefail'; \
46+
printf '%s\n' ''; \
47+
printf '%s\n' "${UO_ROOT}/setup-env.sh >/dev/null 2>&1 || true"; \
48+
printf '%s\n' 'if [ -f "$HOME/.env_uo.sh" ]; then'; \
49+
printf '%s\n' ' . "$HOME/.env_uo.sh"'; \
50+
printf '%s\n' 'fi'; \
51+
printf '%s\n' "exec ${UO_REAL} \"\$@\""; \
52+
} > /usr/local/bin/uo; \
53+
chmod +x /usr/local/bin/uo
54+
55+
# Convenience for interactive shells
56+
RUN printf '%s\n' \
57+
'if [ -f "$HOME/.env_uo.sh" ]; then . "$HOME/.env_uo.sh"; fi' \
58+
> /etc/profile.d/urbanopt.sh \
59+
&& printf '\n# URBANopt\nif [ -f "$HOME/.env_uo.sh" ]; then . "$HOME/.env_uo.sh"; fi\n' \
60+
>> /etc/bash.bashrc
61+
62+
WORKDIR /work
63+
64+
CMD ["uo", "--version"]

README.md

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,88 @@
1-
# docker-urbanopt
1+
# urbanopt-cloud
2+
3+
Docker container for URBANopt CLI 1.1.0 on Ubuntu 22.04.
4+
5+
## Overview
6+
7+
This repository contains a Dockerfile that builds a Docker container with URBANopt CLI 1.1.0 installed on Ubuntu 22.04. The container is automatically built, tested, and pushed to Docker Hub via GitHub Actions.
8+
9+
## Features
10+
11+
- **URBANopt CLI 1.1.0**: Pre-installed and configured
12+
- **Ubuntu 22.04**: Base image with all required dependencies
13+
- **Automated CI/CD**: GitHub Actions workflow for building, testing, and publishing
14+
- **Versioning**: Automatic semantic versioning via Git tags
15+
16+
## Usage
17+
18+
### Pull from Docker Hub
19+
20+
```bash
21+
docker pull brianlball/urbanopt-cloud:latest
22+
```
23+
24+
### Run the Container
25+
26+
```bash
27+
# Run with default command (shows version)
28+
docker run --rm brianlball/urbanopt-cloud:latest
29+
30+
# Run interactively
31+
docker run -it --rm brianlball/urbanopt-cloud:latest bash
32+
33+
# Run with a mounted workspace
34+
docker run -it --rm -v $(pwd):/work brianlball/urbanopt-cloud:latest
35+
```
36+
37+
### Build Locally
38+
39+
```bash
40+
docker build -t urbanopt-cloud:latest .
41+
```
42+
43+
## GitHub Actions Workflow
44+
45+
The repository includes a GitHub Actions workflow that:
46+
47+
1. **Builds** the Docker container
48+
2. **Tests** the container by running `uo --version`
49+
3. **Pushes** to Docker Hub with appropriate tags:
50+
- `latest` - for commits to main/master branch
51+
- `<branch>` - for branch commits
52+
- `v1.0.0`, `v1.0`, `v1` - for semantic version tags
53+
- `<branch>-<sha>` - for commit SHA references
54+
55+
### Docker Hub Configuration
56+
57+
To enable automatic pushing to Docker Hub, configure the following repository secrets:
58+
59+
1. Go to your repository **Settings****Secrets and variables****Actions**
60+
2. Click **"New repository secret"**
61+
3. Add the following secrets:
62+
- `DOCKER_USERNAME`: Your Docker Hub username
63+
- `DOCKER_PASSWORD`: Your Docker Hub password or access token
64+
65+
### Versioning
66+
67+
To create a new versioned release:
68+
69+
```bash
70+
git tag -a v1.0.0 -m "Release version 1.0.0"
71+
git push origin v1.0.0
72+
```
73+
74+
## Architecture Support
75+
76+
The Dockerfile supports both x86_64 (default) and arm64 architectures. To build for a specific architecture, use the `UO_ARCH` build argument:
77+
78+
```bash
79+
# Build for x86_64 (default)
80+
docker build -t urbanopt-cloud:x86_64 .
81+
82+
# Build for arm64
83+
docker build --build-arg UO_ARCH=arm64 -t urbanopt-cloud:arm64 .
84+
```
85+
86+
## License
87+
88+
See the URBANopt CLI license for details.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.0

0 commit comments

Comments
 (0)