Skip to content

Commit

Permalink
feat: consolidate deployment targets and publish to ghcr.io (#2539)
Browse files Browse the repository at this point in the history
* WIP: proof of concept

* basic meta tag injection

* add support for scraping public/private links

* make tests go brrrrr

* cleanup initialization

* rewrite build config

* remove recipe meta on frontend

* make type checker happy

* remove other deployment methods

* fix issue with JSON response on un-authenticated request

* docs updates

* update tivy scanner

* fix linter stuff

* change registry tag

* build fixes

* fix same mistake I always make
  • Loading branch information
hay-kot authored Sep 14, 2023
1 parent aec4cb4 commit 2ad6af2
Show file tree
Hide file tree
Showing 34 changed files with 267 additions and 792 deletions.
22 changes: 1 addition & 21 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,4 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_NIGHTLY_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: "🚀 New builds of mealie:api-nightly, mealie:frontend-nightly, and mealie:omni-nightly are available"

deploy-demo:
runs-on: ubuntu-latest
name: Deploy Demo
needs:
- build-release
steps:
- name: Clean and Deploy Demo
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEMO_SERVER_IP }}
username: ${{ secrets.DEMO_SERVER_USER }}
key: ${{ secrets.DEMO_SERVER_SSH_KEY }}
port: ${{ secrets.DEMO_SERVER_PORT }}
script_stop: true
script: |
cd ~/docker/mealie
docker-compose pull
docker-compose down -v
docker-compose up -d
args: "🚀 New builds of ghcr.io/mealie-recipes/mealie:nightly"
144 changes: 9 additions & 135 deletions .github/workflows/partial-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,163 +13,37 @@ on:
required: true

jobs:
build-frontend:
publish:
runs-on: ubuntu-latest
name: Build Frontend
permissions:
contents: read
packages: write
steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
hkotel/mealie
ghcr.io/${{ github.repository }}
- name: Build and push Frontend images
uses: docker/build-push-action@v4
with:
file: docker/frontend.Dockerfile
context: .
push: true
tags: frontend-${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

build-backend:
runs-on: ubuntu-latest
name: Build Backend
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Override __init__.py
run: |
echo "__version__ = \"${{ inputs.tag }}\"" > ./mealie/__init__.py
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
hkotel/mealie
ghcr.io/${{ github.repository }}
- name: Build and push API images
uses: docker/build-push-action@v4
with:
file: docker/api.Dockerfile
context: .
push: true
tags: api-${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

build-omni:
runs-on: ubuntu-latest
name: Build Omni
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Override __init__.py
run: |
echo "__version__ = \"${{ inputs.tag }}\"" > ./mealie/__init__.py
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
hkotel/mealie
ghcr.io/${{ github.repository }}
- name: Build and push API images
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: docker/omni.Dockerfile
file: ./docker/Dockerfile
context: .
push: true
tags: omni-${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{ inputs.tag }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Trivy Backend Container Scanning
name: Trivy Container Scanning

on:
workflow_call:

jobs:
build:
name: Build and Scan Backend Container
name: Build and Scan Container
runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand All @@ -15,7 +15,7 @@ jobs:

- name: Build Dockerfile
run: |
docker build -t mealie --file=./docker/api.Dockerfile .
docker build -t mealie --file=./docker/Dockerfile .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/partial-trivy-frontend-container-scanning.yml

This file was deleted.

10 changes: 3 additions & 7 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ jobs:
name: "Frontend and End-to-End Tests"
uses: ./.github/workflows/partial-frontend.yml

backend-container-scanning:
name: "Trivy Backend Container Scanning"
uses: ./.github/workflows/partial-trivy-backend-container-scanning.yml

frontend-container-scanning:
name: "Trivy Frontend Container Scanning"
uses: ./.github/workflows/partial-trivy-frontend-container-scanning.yml
container-scanning:
name: "Trivy Container Scanning"
uses: ./.github/workflows/partial-trivy-container-scanning.yml
14 changes: 4 additions & 10 deletions docker/omni.Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ RUN yarn install \
# https://github.com/docker/build-push-action/issues/471
--network-timeout 1000000

RUN yarn build

RUN rm -rf node_modules && \
NODE_ENV=production yarn install \
--prefer-offline \
--pure-lockfile \
--non-interactive \
--production=true
RUN yarn generate

###############################################
# Base Image - Python
Expand Down Expand Up @@ -150,12 +143,13 @@ HEALTHCHECK CMD python $MEALIE_HOME/mealie/scripts/healthcheck.py || exit 1
# Copy Frontend

# copying caddy into image
COPY --from=builder /app $MEALIE_HOME/frontend/
ENV STATIC_FILES=/spa/static
COPY --from=builder /app/dist ${STATIC_FILES}

ENV HOST 0.0.0.0

EXPOSE ${APP_PORT}
COPY ./docker/omni.entry.sh $MEALIE_HOME/run.sh
COPY ./docker/entry.sh $MEALIE_HOME/run.sh

RUN chmod +x $MEALIE_HOME/run.sh
ENTRYPOINT $MEALIE_HOME/run.sh
Loading

0 comments on commit 2ad6af2

Please sign in to comment.