Skip to content

Commit

Permalink
feat: add a devcontainer for easier development
Browse files Browse the repository at this point in the history
This change adds a devcontainer that adds `cscli` so that someone can
easily run tests in this repository.

I verified this works by running the example test command in the
`README.md`:
```sh
cscli hubtest run dovecot-logs
INFO[26-02-2025 19:00:00] Running test 'dovecot-logs'                  
INFO[26-02-2025 19:00:03] Test 'dovecot-logs' passed successfully (387 assertions) 
───────────────────────
 Test           Result 
───────────────────────
 dovecot-logs   ✅     
───────────────────────
```

This change also adds a workflow to make sure the devcontainer can
build.
  • Loading branch information
sdwilsh committed Feb 26, 2025
1 parent 5e34fa9 commit f75b2a8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:latest AS builder
RUN wget -q -o /tmp/install-crowdsec-repositories.sh https://install.crowdsec.net \
&& chmod +x /tmp/install-crowdsec-repositories.sh


FROM mcr.microsoft.com/devcontainers/base:debian
COPY --from=builder /tmp/install-crowdsec-repositories.sh /tmp/install-crowdsec-repositories.sh
RUN sh -c /tmp/install-crowdsec-repositories.sh \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
crowdsec \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "CrowdSec Hub",
"build": {
"dockerfile": "Dockerfile"
}
}
22 changes: 22 additions & 0 deletions .github/workflows/devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build DevContainer
on:
push:
branches:
- master
paths:
- .devcontainer/**
pull_request:
branches:
- master
paths:
- .devcontainer/**

jobs:
devcontainer-build:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4

- name: Build devcontainer image
uses: devcontainers/[email protected]

0 comments on commit f75b2a8

Please sign in to comment.