Skip to content

Commit 31b4288

Browse files
committed
Add mailpit feature
1 parent 7a0fcde commit 31b4288

File tree

10 files changed

+174
-0
lines changed

10 files changed

+174
-0
lines changed

Diff for: .github/workflows/test.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- gitlab-cli
1919
- hcloud-cli
2020
- infisical-cli
21+
- mailpit
2122
- terraform-backend-git
2223
baseImage:
2324
- debian:latest
@@ -45,6 +46,7 @@ jobs:
4546
- gitlab-cli
4647
- hcloud-cli
4748
- infisical-cli
49+
- mailpit
4850
- terraform-backend-git
4951

5052
steps:

Diff for: README.md

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Please take a closer look at the detailed instructions for the individual featur
1010
- [GitLab CLI](src/gitlab-cli)
1111
- [Hetzner Cloud CLI](src/hcloud-cli)
1212
- [Infisical CLI](src/infisical-cli)
13+
- [Mailpit](src/mailpit)
1314
- [Terraform State management using Git](src/terraform-backend-git)
1415

1516
## Repo and Feature Structure
@@ -28,6 +29,9 @@ Each Feature has its own sub-folder, containing at least a `devcontainer-feature
2829
│ ├── infisical-cli
2930
│ │ ├── devcontainer-feature.json
3031
│ │ └── install.sh
32+
│ ├── mailpit
33+
│ │ ├── devcontainer-feature.json
34+
│ │ └── install.sh
3135
│ ├── terraform-backend-git
3236
│ │ ├── devcontainer-feature.json
3337
│ │ └── install.sh
@@ -47,6 +51,9 @@ Each Feature has its own sub-folder, containing at least a `devcontainer-feature
4751
│ ├── infisical-cli
4852
│ │ ├── scenarios.json
4953
│ │ └── test.sh
54+
│ ├── mailpit
55+
│ │ ├── scenarios.json
56+
│ │ └── test.sh
5057
│ ├── terraform-backend-git
5158
│ │ ├── scenarios.json
5259
│ │ └── test.sh

Diff for: src/mailpit/devcontainer-feature.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"id": "mailpit",
3+
"version": "1.0.0",
4+
"name": "An email and SMTP testing tool with API for developers",
5+
"documentationURL": "https://github.com/skriptfabrik/devcontainer-features/tree/main/src/mailpit",
6+
"description": "Installs Mailpit binary.",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest"
12+
],
13+
"default": "latest",
14+
"description": "Select or enter a Mailpit version."
15+
}
16+
},
17+
"mounts": [
18+
{
19+
"source": "dind-var-lib-mailpit-${devcontainerId}",
20+
"target": "/var/lib/mailpit",
21+
"type": "volume"
22+
}
23+
],
24+
"entrypoint": "/usr/local/share/mailpit-init.sh",
25+
"installsAfter": [
26+
"ghcr.io/devcontainers/features/common-utils"
27+
]
28+
}

Diff for: src/mailpit/install.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
CLI_VERSION="${VERSION:-"latest"}"
6+
7+
# Bring in ID, ID_LIKE, VERSION_ID, VERSION_CODENAME
8+
. /etc/os-release
9+
10+
# Get an adjusted ID independent of distro variants
11+
if [ "${ID}" != "debian" ] && [ "${ID_LIKE}" != "debian" ]; then
12+
echo "Linux distro ${ID} not supported."
13+
exit 1
14+
fi
15+
16+
# Install prerequisites
17+
apt-get -y update
18+
apt-get -y install --no-install-recommends curl ca-certificates jq
19+
20+
# Clean up
21+
apt-get -y clean
22+
rm -rf /var/lib/apt/lists/*
23+
24+
# Fetch latest version if needed
25+
if [ "${CLI_VERSION}" = "latest" ]; then
26+
CLI_VERSION=$(curl -s https://api.github.com/repos/axllent/mailpit/releases/latest | jq -r '.tag_name' | awk '{print substr($1, 2)}')
27+
fi
28+
29+
# Detect current machine architecture
30+
if [ "$(uname -m)" = "aarch64" ]; then
31+
ARCH="arm64"
32+
else
33+
ARCH="amd64"
34+
fi
35+
36+
# Download URL
37+
DOWNLOAD_URL="https://github.com/axllent/mailpit/releases/download/v${CLI_VERSION}/mailpit-linux-${ARCH}.tar.gz"
38+
39+
# Download and install Mailpit
40+
echo "Downloading Mailpit from ${DOWNLOAD_URL}"
41+
curl -sSL "${DOWNLOAD_URL}" | tar -xz -C /usr/local/bin mailpit
42+
43+
# Create entrypoint script
44+
cat << 'EOF' > /usr/local/share/mailpit-init.sh
45+
#!/bin/bash
46+
47+
set -e
48+
49+
mkdir -p /var/lib/mailpit
50+
51+
# Start mailpit
52+
start-stop-daemon --start --background --quiet \
53+
--make-pidfile --pidfile /var/run/mailpit.pid \
54+
--startas /bin/bash -- -c '/usr/local/bin/mailpit -d /var/lib/mailpit/mailpit.db > /var/log/mailpit.log 2>&1'
55+
56+
set +e
57+
58+
# Execute whatever commands were passed in (if any). This allows us
59+
# to set this script to ENTRYPOINT while still executing the default CMD.
60+
exec "$@"
61+
EOF
62+
chmod +x /usr/local/share/mailpit-init.sh

Diff for: test/_global/all_the_clis.sh

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ source dev-container-features-test-lib
1313
check "check for glab" glab --version
1414
check "check for hcloud" hcloud version
1515
check "check for infisical" infisical --version
16+
check "check for mailpit" mailpit version
1617
check "check for terraform-backend-git" terraform-backend-git version
1718

1819
# Report results

Diff for: test/_global/scenarios.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"gitlab-cli": {},
66
"hcloud-cli": {},
77
"infisical-cli": {},
8+
"mailpit": {},
89
"terraform-backend-git": {}
910
}
1011
}

Diff for: test/mailpit/debian.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
7+
# Provides the 'check' and 'reportResults' commands.
8+
source dev-container-features-test-lib
9+
10+
# Definition specific tests
11+
. /etc/os-release
12+
13+
# Scenario-specific tests
14+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
15+
# check <LABEL> <cmd> [args...]
16+
check "distro" test "${ID}" = "debian"
17+
check "check for mailpit" mailpit version
18+
19+
# Report results
20+
# If any of the checks above exited with a non-zero exit code, the test will fail.
21+
reportResults

Diff for: test/mailpit/scenarios.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"debian": {
3+
"image": "debian:latest",
4+
"features": {
5+
"mailpit": {}
6+
}
7+
},
8+
"ubuntu": {
9+
"image": "ubuntu:latest",
10+
"features": {
11+
"mailpit": {}
12+
}
13+
}
14+
}

Diff for: test/mailpit/test.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
7+
# Provides the 'check' and 'reportResults' commands.
8+
source dev-container-features-test-lib
9+
10+
# Feature-specific tests
11+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
12+
# check <LABEL> <cmd> [args...]
13+
check "check for mailpit" mailpit version
14+
15+
# Report results
16+
# If any of the checks above exited with a non-zero exit code, the test will fail.
17+
reportResults

Diff for: test/mailpit/ubuntu.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib
7+
# Provides the 'check' and 'reportResults' commands.
8+
source dev-container-features-test-lib
9+
10+
# Definition specific tests
11+
. /etc/os-release
12+
13+
# Scenario-specific tests
14+
# The 'check' command comes from the dev-container-features-test-lib. Syntax is...
15+
# check <LABEL> <cmd> [args...]
16+
check "distro" test "${ID}" = "ubuntu"
17+
check "check for mailpit" mailpit version
18+
19+
# Report results
20+
# If any of the checks above exited with a non-zero exit code, the test will fail.
21+
reportResults

0 commit comments

Comments
 (0)