Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lloesche committed Sep 10, 2024
0 parents commit b37ec44
Show file tree
Hide file tree
Showing 24 changed files with 1,630 additions and 0 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @lloesche @aquamatthias @meln1k
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Description

<!-- Please describe the changes included in this PR here. -->

# To-Dos

<!-- Before submitting this PR, please lint and test your changes locally. -->
<!-- Add an 'x' between the brackets to mark each checkbox as checked. -->
<!-- (Feel free to remove any items that do not apply to this PR.) -->

- [ ] Add test coverage for new or updated functionality
- [ ] Lint and test with `tox`
- [ ] Document new or updated functionality (someengineering/resoto.com#XXXX)

# Issues Fixed

<!-- If this PR will fix/resolve an open issue on the repository, please reference it below. -->
<!-- (Otherwise, feel free to delete this section.) -->

- Fixes #XXXX

# Code of Conduct

By submitting this pull request, I agree to follow the [code of conduct](https://fix.tt/code-of-conduct).
97 changes: 97 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build Docker Images

on:
push:
tags:
- "*.*.*"
branches:
- main
pull_request:
workflow_dispatch:

jobs:
split-build:
name: "Build Docker images"
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Get short commit SHA
id: sha
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- name: Set build platforms
id: platform
run: |
GITHUB_REF="${{ github.ref }}"
GITHUB_TAG=${GITHUB_REF##*/}
echo "targets=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
if [ "${{ github.ref_type }}" = tag ]; then
if [[ "$GITHUB_TAG" =~ [0-9]([ab]|rc)[0-9]* ]]; then
echo "latest=false" >> $GITHUB_OUTPUT
else
echo "latest=true" >> $GITHUB_OUTPUT
fi
else
echo "latest=false" >> $GITHUB_OUTPUT
fi
- name: Docker Metadata
id: basemeta
uses: docker/metadata-action@v5
with:
images: |
someengineering/fixattiosync
ghcr.io/someengineering/fixattiosync
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=fixbackup
org.opencontainers.image.description=FIX DB Backup System
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,amd64

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
SOURCE_COMMIT=${{ github.sha }}
tags: ${{ steps.basemeta.outputs.tags }}
labels: ${{ steps.basemeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533
30 changes: 30 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run tests
on:
push:
tags:
- "*.*.*"
branches:
- main
pull_request:

jobs:
tox:
name: "tox"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x64'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install tox wheel flake8 build
- name: Run tests
run: tox
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
__pycache__
this
.idea/
tmp/
runner.env
artifacts/
*~
*backups
.cache
docker-tag
.tox/
.*.swp
*.egg-info
wheelhouse/
test/build/*
PASSED
FAILED
test/.vagrant/*
.pytest_cache
.eggs/
venv*
/config/
*.code-workspace
*/build/
docs/_build/
.DS_Store
.coverage
.dccache
resotoshell/backup_*
resotocore/tools/Assets
out/
*.iml
**/.hypothesis/
.sandbox/*
.env
75 changes: 75 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM fedora:40 AS build-env
ENV LANG="C.UTF-8"
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TESTS
ARG SOURCE_COMMIT

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN echo "I am running on ${BUILDPLATFORM}, building for ${TARGETPLATFORM}"

WORKDIR /
RUN dnf -y update \
&& dnf -y groupinstall "Development Tools" "Development Libraries" \
&& dnf -y install \
gcc \
python3-devel \
python3-pip \
shellcheck \
curl \
ca-certificates \
dateutils \
openssl \
openssl-devel \
rustc \
cargo \
git

# Create CPython venv
WORKDIR /usr/local
RUN python3 -m venv fix-venv-python3

# Download and install Python test tools
RUN . /usr/local/fix-venv-python3/bin/activate && python -m pip install -U pip wheel tox flake8

# Build Fix Inventory
COPY . /usr/src/fixattiosync

WORKDIR /usr/src/fixattiosync
RUN . /usr/local/fix-venv-python3/bin/activate && pip install -r requirements.txt
RUN . /usr/local/fix-venv-python3/bin/activate && python -m pip install .

COPY bootstrap /usr/local/sbin/bootstrap
RUN chmod 755 \
/usr/local/sbin/bootstrap
RUN echo "${SOURCE_COMMIT:-unknown}" > /usr/local/etc/git-commit.HEAD


# Setup main image
FROM fedora:40
ENV LANG="C.UTF-8"
ENV TERM="xterm-256color"
ENV COLORTERM="truecolor"
ENV EDITOR="vim"
COPY --from=build-env /usr/local /usr/local
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
WORKDIR /
RUN groupadd -g "${PGID:-0}" -o fix \
&& useradd -g "${PGID:-0}" -u "${PUID:-0}" -o --create-home fix \
&& dnf -y update \
&& dnf -y install \
dumb-init \
python3 \
python3-pip \
iproute \
libffi \
openssl \
procps \
dateutils \
curl \
ca-certificates \
&& dnf clean all \
&& rm -rf /var/cache/dnf /tmp/* /var/tmp/*

ENTRYPOINT ["/bin/dumb-init", "--", "/usr/local/sbin/bootstrap"]
CMD ["/bin/bash"]
Loading

0 comments on commit b37ec44

Please sign in to comment.