Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize prerelease website #66

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: weekly
11 changes: 0 additions & 11 deletions .github/workflows/bootstrap.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Build and install python packages
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
57 changes: 57 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Create and publish a Docker image

on:
push:
branches:
- master
pull_request:
schedule:
- cron: '45 18 * * 3'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6:45PM on Wednesday.


env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export Docker image
uses: docker/build-push-action@v5
with:
context: .
tags: ros-infrastructure/prerelease_website:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Log in to the Container registry
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=schedule,${{ github.ref_name }}
- name: Build and push Docker image
if: contains(fromJSON('["push", "schedule"]'), github.event_name)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.11-alpine

COPY requirements.txt /prerelease_website/requirements.txt
WORKDIR /prerelease_website
RUN pip --no-cache-dir install -r requirements.txt
COPY . /prerelease_website
ENTRYPOINT ["/prerelease_website/entrypoint.sh"]
EXPOSE 5000
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
exec gunicorn \
-u nobody \
-g nobody \
--access-logfile '-' \
--error-logfile '-' \
--log-file "-" \
--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"' \
--forwarded-allow-ips="140.211.9.104,2605:bc80:3010:104::8cd3:968" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may send a follow-up PR that breaks these values out into a variable so they can be described in a comment for future me who forgets what these IPs are.

-w 4 \
-b 0.0.0.0:5000 \
'wsgi:app'
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
blinker==1.8.2
catkin-pkg==1.0.0
click==8.1.7
configparser==7.0.0
distro==1.9.0
docutils==0.21.2
empy==4.1
Flask==3.0.3
gunicorn==22.0.0
itsdangerous==2.2.0
Jinja2==3.1.4
MarkupSafe==2.1.5
packaging==24.1
pyparsing==3.1.2
python-dateutil==2.9.0.post0
PyYAML==6.0.1
ros-buildfarm==3.0.0
rosdistro==0.9.1
rosinstall-generator==0.1.23
rospkg==1.5.1
six==1.16.0
vcstool==0.3.0
Werkzeug==3.0.3
4 changes: 4 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from prerelease_website import app

if __name__ == "__main__":
app.run()