Skip to content

Commit

Permalink
Update dockerfile and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Dec 28, 2024
1 parent 97532de commit 7e89b98
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docs
tests
.github
.nox
.venv
23 changes: 20 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@ name: Docker
on:
push:
branches:
- '*'
- main
tags:
- '*'
paths-ignore:
- 'docs/**'
pull_request:
branches:
- main

jobs:
docker:
runs-on: ubuntu-latest
name: Docker

runs-on: ubuntu-24.04

env:
USER: sdss
APP: lvmguider

steps:
- name: Set docker tags
id: set-tags
Expand All @@ -26,23 +33,33 @@ jobs:
then
BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's/[\/]/_/g')
echo TAGS=$USER/$APP:$BRANCH >> $GITHUB_OUTPUT
elif [[ $GITHUB_REF == refs/pull/* ]]
then
BRANCH=${{ github.head_ref || github.ref_name }}
echo TAGS=$USER/$APP:$BRANCH >> $GITHUB_OUTPUT
else
echo TAGS=$USER/$APP:${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
fi
- name: Show tags
run: echo ${{ steps.set-tags.outputs.TAGS }}

- 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 registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
file: docker/Dockerfile
push: true
provenance: false
tags: ghcr.io/${{ steps.set-tags.outputs.TAGS }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
12 changes: 8 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ jobs:
lint:
name: Lint

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
python-version: '3.13'

- name: Lint with ruff
run: |
pip install ruff
uv tool install ruff
ruff check src/ tests/
ruff format --check src/ tests/
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
release:
name: Build and publish

runs-on: ubuntu-latest
runs-on: ubuntu-24.04

permissions:
contents: write
Expand All @@ -27,7 +27,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install uv
uses: astral-sh/setup-uv@v4
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test

on:
push:
paths-ignore:
- 'docs/**'
pull_request:
paths-ignore:
- 'docs/**'

jobs:
test:
name: Test

runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']

env:
OBSERVATORY: 'LCO'

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies
run: |
uv sync --no-dev --frozen
- name: Test with pytest
run: |
uv pip install pytest pytest-mock pytest-asyncio pytest-cov
uv run pytest
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v5
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./coverage.xml
24 changes: 14 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM python:3.11-slim-bookworm
FROM python:3.12-slim-bookworm
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

MAINTAINER Jose Sanchez-Gallego, [email protected]
LABEL org.opencontainers.image.source https://github.com/sdss/lvmguider
LABEL org.opencontainers.image.authors="Jose Sanchez-Gallego, [email protected]"
LABEL org.opencontainers.image.source=https://github.com/sdss/lvmguider

WORKDIR /opt

Expand All @@ -15,22 +16,25 @@ COPY docker/matplotlibrc /root/.config/matplotlib/
COPY docker/LiberationSerif-Regular.ttf /usr/share/fonts/

# Refresh system font cache
RUN apt update -y
RUN apt install -y fontconfig
RUN apt-get update -y
RUN apt-get install -y fontconfig
RUN fc-cache -f -v

# Refresh matplotlib font cache
RUN rm -fr ~/.cache/matplotlib

RUN apt install -y build-essential
RUN apt install -y astrometry.net
RUN apt-get install -y build-essential
RUN apt-get install -y astrometry.net

# Ignore warnings about installing as packages with pip as root.
ENV PIP_ROOT_USER_ACTION=ignore

RUN pip3 install -U pip setuptools wheel
RUN cd lvmguider && pip3 install .
RUN rm -Rf lvmguider
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV PATH="$PATH:/opt/lvmguider/.venv/bin"

# Sync the project
RUN cd lvmguider && uv sync --frozen --no-cache --no-dev

# Set umask so that new files inherit the parent folder permissions.
# Not sure this works so we are also setting the permissions in the entrypoint.
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
umask 0002

pip3 install -U astropy-iers-data
uv pip install -U astropy-iers-data
exec "$@"

0 comments on commit 7e89b98

Please sign in to comment.