Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Commit 1406f13

Browse files
authored
Dockerize prerelease website (#66)
This will allow the OSL to manage this as a docker container and handle updates better in the long term. Some key changes: - Add weekly dependabot checks - Add requirements.txt - Add basic CI - Build and release container images on ghcr.io which will be used in the cookbook - Do a weekly build regardless of any dependabot bumps - Deploy website using gunicorn instead of mod_python - Create wsgi.py for gunicorn Signed-off-by: Lance Albertson <[email protected]>
1 parent 1d19acc commit 1406f13

File tree

8 files changed

+133
-11
lines changed

8 files changed

+133
-11
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: pip
5+
directory: /
6+
schedule:
7+
interval: weekly

.github/workflows/bootstrap.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Build and install python packages
3+
on: [push]
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
python-version:
10+
- "3.11"
11+
- "3.12"
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -r requirements.txt

.github/workflows/container.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
name: Create and publish a Docker image
3+
4+
on:
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
schedule:
10+
- cron: '45 18 * * 3'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
15+
16+
jobs:
17+
docker:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
- name: Build and export Docker image
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: .
31+
tags: ros-infrastructure/prerelease_website:test
32+
cache-from: type=gha
33+
cache-to: type=gha,mode=max
34+
- name: Log in to the Container registry
35+
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Extract metadata (tags, labels) for Docker
42+
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
tags: |
48+
type=ref,event=branch
49+
type=schedule,${{ github.ref_name }}
50+
- name: Build and push Docker image
51+
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM python:3.11-alpine
2+
3+
COPY requirements.txt /prerelease_website/requirements.txt
4+
WORKDIR /prerelease_website
5+
RUN pip --no-cache-dir install -r requirements.txt
6+
COPY . /prerelease_website
7+
ENTRYPOINT ["/prerelease_website/entrypoint.sh"]
8+
EXPOSE 5000

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
exec gunicorn \
3+
-u nobody \
4+
-g nobody \
5+
--access-logfile '-' \
6+
--error-logfile '-' \
7+
--log-file "-" \
8+
--access-logformat '%({x-forwarded-for}i)s %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' \
9+
--forwarded-allow-ips="140.211.9.104,2605:bc80:3010:104::8cd3:968" \
10+
-w 4 \
11+
-b 0.0.0.0:5000 \
12+
'wsgi:app'

requirements.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
blinker==1.8.2
2+
catkin-pkg==1.0.0
3+
click==8.1.7
4+
configparser==7.0.0
5+
distro==1.9.0
6+
docutils==0.21.2
7+
empy==4.1
8+
Flask==3.0.3
9+
gunicorn==22.0.0
10+
itsdangerous==2.2.0
11+
Jinja2==3.1.4
12+
MarkupSafe==2.1.5
13+
packaging==24.1
14+
pyparsing==3.1.2
15+
python-dateutil==2.9.0.post0
16+
PyYAML==6.0.1
17+
ros-buildfarm==3.0.0
18+
rosdistro==0.9.1
19+
rosinstall-generator==0.1.23
20+
rospkg==1.5.1
21+
six==1.16.0
22+
vcstool==0.3.0
23+
Werkzeug==3.0.3

wsgi.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from prerelease_website import app
2+
3+
if __name__ == "__main__":
4+
app.run()

0 commit comments

Comments
 (0)