Skip to content

Commit

Permalink
Squash the commits below: (#47)
Browse files Browse the repository at this point in the history
- Add docker.yml workflow

- Remove poetry.lock from Dockerfiles

 -  This is because these files are in .gitignore and our GitHub Action will not work if these files are requested.

- Bugfix: update docker.yml -- Add login step

- Bugfix: update docker.yml -- Add permissions

- Add --no-root to Dockerfiles

  - This is because we do not copy the project files to the build until
after Poetry is run.
  • Loading branch information
yinchi authored Jul 25, 2024
1 parent 27e0d16 commit a4e01b1
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 8 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Docker build push"

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
packages: write
id-token: write

jobs:
bake:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/bake-action@v5
with:
push: true
4 changes: 2 additions & 2 deletions dighosp-des/api.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc
RUN mkdir /app
COPY pyproject.toml poetry.lock /app/
COPY pyproject.toml /app/

RUN cd /app && poetry install --no-interaction --no-ansi --without dev
RUN cd /app && poetry install --no-interaction --no-ansi --no-root --without dev

######

Expand Down
4 changes: 2 additions & 2 deletions dighosp-des/des-worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc
RUN mkdir /app
COPY pyproject.toml poetry.lock /app/
COPY pyproject.toml /app/

RUN cd /app && poetry install --no-interaction --no-ansi --without dev
RUN cd /app && poetry install --no-interaction --no-ansi --no-root --without dev

########################################

Expand Down
5 changes: 3 additions & 2 deletions dighosp-docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc make

WORKDIR /dighosp-docs

COPY ./pyproject.toml /dighosp-docs/pyproject.toml
RUN poetry install --no-interaction --no-ansi
COPY ./pyproject.toml /dighosp-docs/

RUN poetry install --no-interaction --no-ansi --no-root

COPY ./source/ /dighosp-docs/source/
COPY ./Makefile /dighosp-docs/Makefile
Expand Down
4 changes: 2 additions & 2 deletions dighosp-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install gcc
RUN mkdir /app
COPY pyproject.toml poetry.lock /app/
COPY pyproject.toml /app/

RUN cd /app && poetry install --no-interaction --no-ansi --without dev
RUN cd /app && poetry install --no-interaction --no-ansi --no-root --without dev

######

Expand Down
54 changes: 54 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
variable "TAG" {
default = "latest"
}

group "default" {
targets = [
"des-api",
"des-worker",
"docs",
"frontend",
"webproxy"
]
}

target "des-api" {
context = "dighosp-des"
dockerfile = "api.Dockerfile"
tags = [
"ghcr.io/cam-digital-hospitals/monorepo-des-api:${TAG}"
]
}

target "des-worker" {
context = "dighosp-des"
dockerfile = "des-worker.Dockerfile"
tags = [
"ghcr.io/cam-digital-hospitals/monorepo-des-worker:${TAG}"
]
}

target "docs" {
context = "dighosp-docs"
dockerfile = "Dockerfile"
tags = [
"ghcr.io/cam-digital-hospitals/monorepo-docs:${TAG}"
]
}

target "frontend" {
context = "dighosp-frontend"
contexts = {assets = "assets"}
dockerfile = "Dockerfile"
tags = [
"ghcr.io/cam-digital-hospitals/monorepo-frontend:${TAG}"
]
}

target "webproxy" {
context = "nginx"
dockerfile = "Dockerfile"
tags = [
"ghcr.io/cam-digital-hospitals/monorepo-webproxy:${TAG}"
]
}

0 comments on commit a4e01b1

Please sign in to comment.