-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Build container image and provide compose file
Allow to use greenbone-scap-api via docker compose.
- Loading branch information
1 parent
4df1f1d
commit 17417b5
Showing
5 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Container Image Builds | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
tags: ["v*"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
images: | ||
name: Build images | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ vars.IMAGE_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Setup container meta information | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ vars.IMAGE_REGISTRY }}/${{ github.repository }} | ||
labels: | | ||
org.opencontainers.image.vendor=Greenbone | ||
org.opencontainers.image.base.name=debian:stable-slim | ||
tags: | | ||
# create container tag for git tags | ||
type=ref,event=tag | ||
# set edge for default branch | ||
type=edge | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and push Container image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
file: docker/Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
FROM debian:stable-slim as builder | ||
|
||
COPY . /source | ||
|
||
WORKDIR /source | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends --no-install-suggests -y \ | ||
python3 \ | ||
python-is-python3 \ | ||
pipx && \ | ||
apt-get remove --purge --auto-remove -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN pipx install poetry | ||
|
||
RUN rm -rf dist && /root/.local/bin/poetry build -f wheel | ||
|
||
FROM debian:stable-slim | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PIP_NO_CACHE_DIR off | ||
|
||
WORKDIR /greenbone-scap-api | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends --no-install-suggests -y \ | ||
gosu \ | ||
python3 \ | ||
python-is-python3 \ | ||
python3-pip \ | ||
libpq5 && \ | ||
apt-get remove --purge --auto-remove -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN addgroup --gid 1001 --system greenbone && \ | ||
adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group greenbone | ||
|
||
COPY --from=builder /source/dist/* /greenbone-scap-api/ | ||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint | ||
|
||
RUN python3 -m pip install --break-system-packages /greenbone-scap-api/* | ||
|
||
RUN chown -R greenbone:greenbone /greenbone-scap-api && \ | ||
chmod 755 /usr/local/bin/entrypoint | ||
|
||
ENTRYPOINT [ "/usr/local/bin/entrypoint" ] | ||
|
||
CMD ["greenbone-scap-api"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: greenbone-scap | ||
|
||
services: | ||
db: | ||
image: postgres:15-bookworm | ||
restart: always | ||
environment: | ||
POSTGRES_DB: scap | ||
POSTGRES_USER: scap | ||
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
ports: | ||
- 5432:5432 | ||
|
||
cve: | ||
image: ghcr.io/greenbone/greenbone-scap | ||
depends_on: | ||
- db | ||
environment: | ||
DATABASE_HOST: db | ||
DATABASE_NAME: scap | ||
DATABASE_USER: scap | ||
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | ||
NVD_API_KEY: ${NVD_API_KEY} | ||
volumes: | ||
- data:/mnt/data | ||
command: ["greenbone-cve-download", "--since-from-file", "/mnt/data/last-cve-download", "--store-runtime", "/mnt/data/last-cve-download"] | ||
|
||
cve-api: | ||
image: ghcr.io/greenbone/greenbone-scap-api | ||
depends_on: | ||
- db | ||
environment: | ||
DATABASE_HOST: db | ||
DATABASE_NAME: scap | ||
DATABASE_USER: scap | ||
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | ||
API_HOST: 0.0.0.0 | ||
ports: | ||
- 8000:8000 | ||
|
||
volumes: | ||
postgres: | ||
data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
exec gosu greenbone "$@" |