Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5a0d056
Initial configuration to split configuration to containers
tonalitech702 Dec 31, 2024
98aafa1
Some additional fixes/changes
jhuntwork Jan 8, 2025
2c88e8b
Added K8s CronJobs of default MISP cronjobs
jeremiah-RENISAC Jul 8, 2025
91513b3
Updated supervisored path
jeremiah-RENISAC Jul 8, 2025
21f6c9a
Removed cron container in favor of K8s cronjobs.
jeremiah-RENISAC Jul 8, 2025
11f6111
Prevent breaking existing setups per oivindoh comment
jeremiah-RENISAC Jul 8, 2025
83e5298
Changed workflows target repo to variable
jeremiah-RENISAC Jul 10, 2025
2f05fc8
Merge pull request #1 from jeremiah-RENISAC/workflows_repo_fix
jeremiah-RENISAC Jul 10, 2025
aaaaea2
Force repository owner variable to lowercase (required by ghcr)
jeremiah-RENISAC Jul 10, 2025
0b7899f
Merge pull request #2 from jeremiah-RENISAC/workflows_repo_fix
jeremiah-RENISAC Jul 10, 2025
bc687a9
Swapped from container_name to _service as container_name isn't autom…
jeremiah-RENISAC Jul 10, 2025
53e26ff
Removed cron entrypoint customizations as tasks refactored to k8s cro…
jeremiah-RENISAC Jul 10, 2025
aff80ac
moved k8s yaml location outside of core
jeremiah-RENISAC Jul 10, 2025
4d8f299
Merge pull request #3 from jeremiah-RENISAC/kubernetes_config
jeremiah-RENISAC Jul 10, 2025
70cea7f
added manual trigger of workflow
jeremiah-RENISAC Jul 16, 2025
1ec60c2
Merge pull request #4 from jeremiah-RENISAC/manual_workflow_trigger
jeremiah-RENISAC Jul 16, 2025
b898686
Updated to new core version
jeremiah-RENISAC Jul 16, 2025
504ff01
Merge pull request #5 from jeremiah-RENISAC/core-update
jeremiah-RENISAC Jul 16, 2025
475ca25
Revert "Kubernetes config"
jeremiah-RENISAC Jul 17, 2025
fc72e46
Merge pull request #6 from jeremiah-RENISAC/revert-3-kubernetes_config
jeremiah-RENISAC Jul 17, 2025
2452fce
Split nginx into standalone container built as misp-web
jeremiah-RENISAC Jul 17, 2025
65c0062
Revert "Revert "Kubernetes config""
jeremiah-RENISAC Jul 17, 2025
2c4a5d4
Merge pull request #7 from jeremiah-RENISAC/revert-6-revert-3-kuberne…
jeremiah-RENISAC Jul 17, 2025
7c9acc1
Merge branch 'master' into kubernetes_config
jeremiah-RENISAC Jul 17, 2025
14145af
Fixed indenting and brackets
jeremiah-RENISAC Jul 17, 2025
c246d07
Merge branch 'kubernetes_config' of https://github.com/jeremiah-RENIS…
jeremiah-RENISAC Jul 17, 2025
fe716e1
Fixed brackets
jeremiah-RENISAC Jul 17, 2025
39fa3bf
Removed web_tag as this isn't sourced from the main projects
jeremiah-RENISAC Jul 17, 2025
5da4de2
Added misp-web as target
jeremiah-RENISAC Jul 17, 2025
d3037eb
Added misp-web to matrix targets
jeremiah-RENISAC Jul 17, 2025
1ca3bb4
Update test build to include building misp-web as well
jeremiah-RENISAC Jul 17, 2025
723f8d4
Updated workflows cp command
jeremiah-RENISAC Jul 17, 2025
60f9317
Moved the web dockerfile to the core folder to reduce changes to main…
jeremiah-RENISAC Jul 17, 2025
0372dc7
Reverted test build yaml
jeremiah-RENISAC Jul 17, 2025
43af84d
Trailing slashes to web dockerfile
jeremiah-RENISAC Jul 17, 2025
259f6e4
Removed wildcard files copy command
jeremiah-RENISAC Jul 17, 2025
48c7f97
added debug
jeremiah-RENISAC Jul 17, 2025
a8554e7
Moved chown into the copying step
jeremiah-RENISAC Jul 17, 2025
cd405a3
Absolute entrypoint paths
jeremiah-RENISAC Jul 17, 2025
0d55194
Fixed if statement syntax
jeremiah-RENISAC Jul 17, 2025
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
6 changes: 4 additions & 2 deletions .github/workflows/release-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Build the Docker images and push them to the container registry
on:
push:
branches: [ "master" ]
workflow_dispatch: # manual trigger

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
target: [misp-core, misp-modules, misp-core-slim, misp-modules-slim]
target: [misp-core, misp-modules, misp-core-slim, misp-modules-slim, misp-web]

permissions:
contents: read
Expand All @@ -32,7 +33,8 @@ jobs:
run: |
sed -e '/^[[:space:]]*$/d' -e '/[#@]/d' -e 's/\"//g' -e 's/\(^[^=]*\)=\(.*\)/\1="\2"/' template.env > env.hcl
echo "COMMIT_HASH=`echo '${{ github.sha }}' | cut -c 1-7`" >> "$GITHUB_ENV"
echo "NAMESPACE=ghcr.io/misp/misp-docker" >> "$GITHUB_ENV"
OWNER=$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')
echo "NAMESPACE=ghcr.io/${OWNER}/misp-docker" >> "$GITHUB_ENV"

- name: Log in to the container registry
uses: docker/login-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
target: [misp-core, misp-modules, misp-core-slim, misp-modules-slim]
target: [misp-core, misp-modules, misp-core-slim, misp-modules-slim, misp-web]

steps:
- name: Checkout repository
Expand Down
27 changes: 27 additions & 0 deletions core/Dockerfile-web
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use a minimal and secure official NGINX image
FROM nginxinc/nginx-unprivileged:stable-alpine

# Set working directory
WORKDIR /app

# Copy necessary from the local 'files' directory into the container
COPY --chown=101:0 files/etc/nginx/ /etc/nginx/
COPY --chown=101:0 files/var/www/html/ /var/www/html/
COPY --chown=101:0 files/entrypoint_nginx.sh /app/.
COPY --chown=101:0 files/entrypoint_k8s_nginx.sh /app/.

#DEBUG
RUN echo "Listing /app:" && ls -la /app && \
echo "Listing /etc/nginx:" && ls -la /etc/nginx && \
echo "Listing /var/www/html:" && ls -la /var/www/html

# Ensure appropriate permissions
RUN chmod -R 755 /etc/nginx /var/www/html /app
# Ensure the entrypoint script is executable
RUN chmod +x /app/entrypoint_k8s_nginx.sh

# Set the entrypoint
ENTRYPOINT ["/app/entrypoint_k8s_nginx.sh"]

# Use a non-root user (already set in nginx-unprivileged image)
USER 101
11 changes: 9 additions & 2 deletions core/files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,12 @@ export NGINX_X_FORWARDED_FOR=${NGINX_X_FORWARDED_FOR:-false}
export NGINX_SET_REAL_IP_FROM=${NGINX_SET_REAL_IP_FROM}
export NGINX_CLIENT_MAX_BODY_SIZE=${NGINX_CLIENT_MAX_BODY_SIZE:-50M}

# start supervisord using the main configuration file so we have a socket interface
/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf
if [ "$MISP_PHP_ONLY" ]; then
# Not ideal, but let supervisord manage the workers still
mv /etc/supervisor/conf.d/10-supervisor.conf{.k8s,}
/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf &
exec /entrypoint_k8s_fpm.sh
else
# start supervisord using the main configuration file so we have a socket interface
/usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf
fi
13 changes: 13 additions & 0 deletions core/files/entrypoint_fpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ change_php_vars() {
sed -i "s/session.use_strict_mode = .*/session.use_strict_mode = 1/" "$FILE"
echo "Configure PHP | Setting 'date.timezone = ${PHP_TIMEZONE}'"
sed -i "s/;?date.timezone = .*/date.timezone = ${PHP_TIMEZONE}/" "$FILE"
sed -i "s|session.cookie_domain = .*|session.cookie_domain = ${BASE_URL}|" "$FILE"
done

for FILE in /etc/php/*/fpm/pool.d/www.conf
Expand Down Expand Up @@ -61,9 +62,21 @@ change_php_vars() {
echo "Configure PHP | Disabling 'pm.status_listen'"
sed -i -E "s/^pm.status_listen =/;pm.status_listen =/" "$FILE"
fi
if [ "$MISP_PHP_ONLY" ] && [ -n "$PHP_HOST" ]; then
echo "Configure PHP | Setting 'listen' to 0.0.0.0:${PHP_FPM_PORT:-9000}"
sed -i "/^listen =/s@=.*@= 0.0.0.0:${PHP_FPM_PORT:-9000}@" "$FILE"
elif [[ -n "$PHP_FPM_SOCK_FILE" ]]; then
echo "Configure PHP | Setting 'listen' to ${PHP_FPM_SOCK_FILE}"
sed -i "/^listen =/s@=.*@= ${PHP_FPM_SOCK_FILE}@" "$FILE"
fi
done
}

# Return to skip running below commands if not sourced
if [ -n "${BASH_SOURCE[0]}" ]; then
return
fi

echo "Configure PHP | Change PHP values ..." && change_php_vars

echo "Configure PHP | Starting PHP FPM"
Expand Down
26 changes: 26 additions & 0 deletions core/files/entrypoint_k8s_fpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -e

source /entrypoint_nginx.sh
source /entrypoint_fpm.sh

# Initialize MySQL
echo "INIT | Initialize MySQL ..." && init_mysql

# Initialize MISP
echo "INIT | Initialize MISP files and configurations ..." && init_misp_data_files
echo "INIT | Update MISP app/files directory ..." && update_misp_data_files
echo "INIT | Enforce MISP permissions ..." && enforce_misp_data_permissions

# Run configure MISP script
echo "INIT | Configure MISP installation ..."
/configure_misp.sh

if [[ -x /custom/files/customize_misp.sh ]]; then
echo "INIT | Customize MISP installation ..."
/custom/files/customize_misp.sh
fi

echo "Configure PHP | Change PHP values ..." && change_php_vars

echo "Configure PHP | Starting PHP FPM"
exec /usr/sbin/php-fpm8.2 -R -F
18 changes: 18 additions & 0 deletions core/files/entrypoint_k8s_nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e

source ./entrypoint_nginx.sh

# Initialize nginx
echo "INIT | Initialize NGINX ..." && init_nginx

# Configure NGINX to connec to PHP-FPM over TCP if a host is provided
if [[ -n "$PHP_FPM_HOST" ]]; then
echo "... setting 'fastcgi_pass' to $PHP_FPM_HOST:${PHP_FPM_PORT:-9000}"
sed -i "s@fastcgi_pass .*;@fastcgi_pass $PHP_FPM_HOST:${PHP_FPM_PORT:-9000};@" /etc/nginx/includes/misp
fi

echo "INIT | Flip NGINX live ..." && flip_nginx true true

# launch nginx as current shell process in container
exec nginx -g 'daemon off;'

12 changes: 11 additions & 1 deletion core/files/entrypoint_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,19 @@ flip_nginx() {
echo "... nginx docroot set to ${NGINX_DOC_ROOT}"
sed -i "s|root.*var/www.*|root ${NGINX_DOC_ROOT};|" /etc/nginx/includes/misp

if [[ "$reload" = "true" ]]; then
if [[ "$reload" = "true" ]] && [[ -z "$KUBERNETES_SERVICE_HOST" ]]; then
echo "... nginx reloaded"
nginx -s reload
fi
}

init_nginx() {
# Optional location of PHP-FPM sock file
if [[ -n "$PHP_FPM_SOCK_FILE" ]]; then
echo "... setting 'fastcgi_pass' to unix:${PHP_FPM_SOCK_FILE}"
sed -i "s@fastcgi_pass .*;@fastcgi_pass unix:${PHP_FPM_SOCK_FILE};@" /etc/nginx/includes/misp
fi

# Adjust timeouts
echo "... adjusting 'fastcgi_read_timeout' to ${FASTCGI_READ_TIMEOUT}"
sed -i "s/fastcgi_read_timeout .*;/fastcgi_read_timeout ${FASTCGI_READ_TIMEOUT};/" /etc/nginx/includes/misp
Expand Down Expand Up @@ -401,6 +407,10 @@ init_nginx() {
flip_nginx false false
}

# Return to skip running below commands if not sourced
if [ -n "${BASH_SOURCE[0]}" ]; then
return
fi

# Initialize MySQL
echo "INIT | Initialize MySQL ..." && init_mysql
Expand Down
12 changes: 12 additions & 0 deletions core/files/etc/supervisor/conf.d/10-supervisor.conf.k8s
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[supervisord]
nodaemon=true
user=root
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[inet_http_server]
port=127.0.0.1:9001
username=supervisor
password=supervisor
8 changes: 8 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ group "default" {
"misp-modules-slim",
"misp-core",
"misp-core-slim",
"misp-web",
]
}

Expand Down Expand Up @@ -160,3 +161,10 @@ target "misp-core-slim" {
}
platforms = "${PLATFORMS}"
}

target "misp-web" {
context = "core/."
dockerfile = "Dockerfile-web"
tags = flatten(["${NAMESPACE}/misp-web:latest", "${NAMESPACE}/misp-web:${COMMIT_HASH}" ])
platforms = "${PLATFORMS}"
}
27 changes: 27 additions & 0 deletions kubernetes/k8s_cronjobs/base/base-api-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: misp-curljob
spec:
schedule: "* * * * *" # Placeholder; Overridden in overlays
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: curl-job
image: curlimages/curl:latest
command: ["/bin/sh", "-c"]
args: ["echo 'Placeholder Command'"] # Placeholder; Overridden in overlays
env:
- name: BASE_URL
valueFrom:
secretKeyRef:
name: misp-cron-secret
key: url
- name: MISP_API_KEY
valueFrom:
secretKeyRef:
name: misp-cron-secret
key: api_key
2 changes: 2 additions & 0 deletions kubernetes/k8s_cronjobs/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- base-api-cronjob.yaml
9 changes: 9 additions & 0 deletions kubernetes/k8s_cronjobs/k8s-misp-cron-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: misp-cron-secret
type: Opaque
stringData:
url: "https://misp.example.com" # Replace with your MISP instance URL
data:
api_key: "" # Base64 encoded value of your MISP API key goes here
9 changes: 9 additions & 0 deletions kubernetes/k8s_cronjobs/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- overlays/cacheFeed
- overlays/fetchFeed
- overlays/pullAll
- overlays/pushAll
- overlays/updateGalaxies
- overlays/updateNoticeLists
- overlays/updateTaxonomies
- overlays/updateWarningLists
7 changes: 7 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/cacheFeed/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- ../../base/

patches:
- path: patch.yaml

nameSuffix: -feed-cache
18 changes: 18 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/cacheFeed/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: misp-curljob
spec:
schedule: "20 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: curl-job
args:
- >
curl -sS -X POST "$BASE_URL/feeds/cacheFeeds/all"
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: $MISP_API_KEY"
7 changes: 7 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/fetchFeed/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- ../../base/

patches:
- path: patch.yaml

nameSuffix: -feed-fetch
18 changes: 18 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/fetchFeed/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: misp-curljob
spec:
schedule: "30 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: curl-job
args:
- >
curl -sS -X POST "$BASE_URL/feeds/fetchFromAllFeeds"
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: $MISP_API_KEY"
7 changes: 7 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/pullAll/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- ../../base/

patches:
- path: patch.yaml

nameSuffix: -pullall
25 changes: 25 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/pullAll/patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: misp-curljob
spec:
schedule: "0 1 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: curl-job
args:
- >
curl -sS -X GET "$BASE_URL/servers"
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: $MISP_API_KEY"
| awk '/"Server":/,/}/'
| grep -o '"id": "[0-9]*"'
| grep -o '[0-9]\+'
| xargs -I {} curl -sS -X POST $BASE_URL/servers/pull/{}
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: $MISP_API_KEY"
7 changes: 7 additions & 0 deletions kubernetes/k8s_cronjobs/overlays/pushAll/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resources:
- ../../base/

patches:
- path: patch.yaml

nameSuffix: -pushall
Loading