Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and Push to ghcr and use prebuilt images #228

Merged
merged 3 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Push Docker Images

on:
push:
tags:
- 'v*'

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure all history and tags are fetched

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

- name: Get git version
run: echo "VERSION=$(git describe --tags --always)" >> $GITHUB_ENV

- name: Build and Push Backend Docker Image
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/backend:${{ env.VERSION }}
ghcr.io/${{ github.repository }}/backend:latest
platforms: linux/amd64,linux/arm64,linux/arm64/v8

- name: Build and Push Frontend Docker Image
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/frontend:${{ env.VERSION }}
ghcr.io/${{ github.repository }}/frontend:latest
platforms: linux/amd64,linux/arm64,linux/arm64/v8
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ The decoupling allows you to save a considerable amount of time:
> The easiest way to get started is through the [free trial of cloud instance available here](https://intuitem.com/trial).


Alternatively, make sure you have *Docker* and *Docker-compose* installed, on your workstation or server, clone the repo and run:
Alternatively, once you have *Docker* and *Docker-compose* installed, on your workstation or server, *clone* the repo and run:

```sh
./docker-compose.sh
```

## Documentation
> [!NOTE]
> The docker-compose script uses prebuilt Docker images supporting most of the standard hardware architecture.
> If you're using **Windows**, Make sure to have [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) installed and trigger the script within a WSL command line. It will feed Docker Desktop on your behalf.

> [!WARNING]
If you're getting warnings or errors about image's platform not matching host platform, raise an issue with the details and we'll add it shortly after. You can also use `docker-compose-build.sh` instead (see below) to build for your specific architecture.

## End-user Documentation

Check out the online documentation on https://intuitem.gitbook.io/ciso-assistant.

Expand Down Expand Up @@ -131,19 +138,26 @@ git clone [email protected]:intuitem/ciso-assistant-community.git
cd ciso-assistant-community
```

2. Launch docker-compose script
2. Launch docker-compose script for prebuilt images:

```sh
./docker-compose.sh
```

*Alternatively*, you can use this variant to build the docker images for your specific architecture:

```sh
./docker-compose-build.sh
```

When asked for, enter your email and password for your superuser.

You can then reach CISO Assistant using your web brower at [https://localhost:8443/](https://localhost:8443/)

For the following executions, use "docker compose up" directly.

If you want to restart a fresh install, simply delete the db directory, where the database is stored.
> [!TIP]
> If you want a fresh install, simply delete the `db` directory, (default: backend/db) where the database is stored.


## Setting up CISO Assistant for development
Expand All @@ -152,6 +166,7 @@ If you want to restart a fresh install, simply delete the db directory, where th

- Python 3.11+
- pip 20.3+
- node 18+
- npm 10.2+

### Running the backend
Expand Down
14 changes: 14 additions & 0 deletions docker-compose-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /usr/bin/env bash

if [ -f db/ciso-assistant.sqlite3 ] ; then
echo "the database seems already created"
echo "you should launch docker compose up -d"
else
docker compose -f docker-compose-build.yml build
docker compose -f docker-compose-build.yml up -d
docker compose exec backend python manage.py migrate
echo "initialize your superuser account..."
docker compose exec backend python manage.py createsuperuser
echo "connect to ciso assistant on https://localhost:8443"
echo "for successive runs you can now use docker compose up"
fi
40 changes: 40 additions & 0 deletions docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3.9"

services:
backend:
container_name: backend
build: ./backend
restart: always
environment:
- ALLOWED_HOSTS=backend
- CISO_ASSISTANT_URL=https://localhost:8443
- DJANGO_DEBUG=True
volumes:
- ./db:/code/db

frontend:
container_name: frontend
environment:
- PUBLIC_BACKEND_API_URL=http://backend:8000/api
- PROTOCOL_HEADER=x-forwarded-proto
- HOST_HEADER=x-forwarded-host

build: ./frontend
depends_on:
- backend

caddy:
container_name: caddy
image: caddy:2.7.6
restart: unless-stopped
ports:
- 8443:8443
command:
- caddy
- reverse-proxy
- --from
- https://localhost:8443
- --to
- frontend:3000
volumes:
- ./db:/data
1 change: 0 additions & 1 deletion docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ if [ -f db/ciso-assistant.sqlite3 ] ; then
echo "the database seems already created"
echo "you should launch docker compose up -d"
else
docker compose build
docker compose up -d
docker compose exec backend python manage.py migrate
echo "initialize your superuser account..."
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.9"
services:
backend:
container_name: backend
build: ./backend
image: ghcr.io/intuitem/ciso-assistant-community/backend:latest
restart: always
environment:
- ALLOWED_HOSTS=backend
Expand All @@ -19,7 +19,7 @@ services:
- PROTOCOL_HEADER=x-forwarded-proto
- HOST_HEADER=x-forwarded-host

build: ./frontend
image: ghcr.io/intuitem/ciso-assistant-community/frontend:latest
depends_on:
- backend

Expand Down
Loading