Easily build Odoo.sh compliant repositories into Ofleet-ready container images.
3.2K
A Docker image, built on top of alpine, to build a custom image using Kaniko for the Ofleet platform and eventually push it to some container registry.
It is compatible with Odoo.sh Github repositories.
ofleet-prepare [OFLEET_BASE_IMAGE] [optional:WORKDIR] : Create a Dockerfile ready to be built, with a repository following the same specs as Odoo.sh.
Example : ofleet-prepare ofleet/odoo:17-20240328-enterprise
ofleet-build [TARGET_IMAGE_NAME] [TARGET_REGISTRY] [TARGET_REGISTRY_USER] [TARGET_REGISTRY_PASSWORD] [optional:WORKDIR] : Auth to the pull & push registries. Build and push the image.
You can pick from any tag available here : https://hub.docker.com/repository/docker/ofleet/odoo/tags
This example will build and push to the GHCR everytime a new commit happens on the
mainbranch.
File .github/workflows/main.yml :
name: Example Workflow (Build and Push)
run-name: Build ${{ github.ref_name }} image
on:
push:
branches:
- main
jobs:
build-and-push:
name: "Ofleet : build & push"
runs-on: ubuntu-latest
container: ofleet/builder:v1-stable
permissions:
contents: read
packages: write
steps:
- name: Check out the repo from branch
uses: actions/checkout@v4
with:
submodules: recursive
# token: ${{ secrets.SUBMODULE_PRIVATE_TOKEN }} if you need to checkout submodules with private token
- name: Build and Push Docker image
env:
OFLEET_ODOO_IMAGE: ofleet/odoo:13-20220523-legacy # Replace with what you want.
DOCKER_REGISTRY: ghcr.io # ${{ vars.DOCKER_REGISTRY }} for public registry (ie. DockerHub)
DOCKER_USERNAME: ${{github.actor}} # ${{ secrets.DOCKER_USERNAME }} for public registry (ie. DockerHub)
DOCKER_PASSWORD: ${{secrets.GITHUB_TOKEN}} # ${{ secrets.DOCKER_PASSWORD }} for public registry (ie. DockerHub)
run: |
ofleet-prepare ${OFLEET_ODOO_IMAGE} ${GITHUB_WORKSPACE}
ofleet-build ${DOCKER_REGISTRY}/my-org/my-project-image:my-tag ${DOCKER_REGISTRY} ${DOCKER_USERNAME} ${DOCKER_PASSWORD} ${GITHUB_WORKSPACE}
This example will build and push to the GitLab container registry everytime a new commit happens.
File .gitlab-ci.yml :
build:
image: ofleet/builder:v1-stable
when: always
stage: build
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- ofleet-prepare ofleet/odoo:13-20220523-legacy $CI_PROJECT_DIR
- ofleet-build $CI_REGISTRY_IMAGE:my-tag $CI_REGISTRY gitlab-ci-token $CI_JOB_TOKEN $CI_PROJECT_DIR
docker pull ofleet/builder:latest