Skip to content

Commit

Permalink
Pre-install system libraries with APK_INSTALL_PACKAGES env var (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Oct 24, 2022
1 parent 5eaea6e commit 1fcf8d5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@ All user visible changes to this project will be documented in this file. This p



## [2.8.28-node19-r0] · 2022-10-19
## [2.8.28-node19-r0] · 2022-10-24
[2.8.28-node19-r0]: /../../tree/v2.8.28-node19-r0

[Diff](/../../compare/v2.8.28-node18-r2...v2.8.28-node19-r0)

### Added

- Ability to pre-install [Alpine Linux] packages via `APK_INSTALL_PACKAGES` environment variable. ([#2])

### Upgraded

- [Node.js] 19: <https://github.com/nodejs/node/blob/v19.0.0/doc/changelogs/CHANGELOG_V19.md#2022-10-18-version-1900-current-rafaelgss-and-ruyadorno>

[#2]: /../../issues/2




Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ docker run -d -p 25:25 \
instrumentisto/haraka
```

#### [Alpine][11] packages

Some plugins (like [`tls`][3]) may require additional system libraries being installed. Use `APK_INSTALL_PACKAGES` environment variable to pre-install them on container startup:
```bash
docker run -d -p 25:25 \
-v /path/to/my/plugins:/etc/haraka/config/plugins:ro \
-e APK_INSTALL_PACKAGES=openssl \
instrumentisto/haraka
```




Expand Down Expand Up @@ -140,8 +150,9 @@ If you have any problems with or questions about this image, please contact us t
[NPM]: https://www.npmjs.com
[SMTP]: https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol

[1]: https://haraka.github.io/manual/Plugins.html
[2]: https://haraka.github.io/Plugins.html#installing-npm-packaged-plugins
[1]: https://haraka.github.io/core/Plugins
[2]: https://haraka.github.io/core/Plugins#plugins-as-modules
[3]: https://haraka.github.io/plugins/tls
[11]: http://alpinelinux.org
[12]: https://hub.docker.com/_/alpine
[13]: http://www.musl-libc.org
Expand Down
8 changes: 8 additions & 0 deletions rootfs/usr/local/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ runCmd() {

set -e

# Install APK (Alpine Package Keeper) packages if required.
if [ ! -z "$APK_INSTALL_PACKAGES" ]; then
packages="$(echo $APK_INSTALL_PACKAGES | sed 's/,/ /g')"
runCmd apk add --update $packages

rm -rf /var/cache/apk/*
fi

# Specify actual hostname.
echo "$HOSTNAME" > /etc/haraka/config/me

Expand Down
18 changes: 18 additions & 0 deletions tests/main.bats
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,21 @@

[ "$actual" = "$expected" ]
}


@test "APK_INSTALL_PACKAGES installs packages" {
run docker run --rm --platform $PLATFORM \
-e APK_INSTALL_PACKAGES=openssl,rclone \
$IMAGE apk list
[ "$status" -eq 0 ]
[ ! "$output" = '' ]
actual="$output"

run sh -c "printf \"$actual\" | grep -E '^openssl-.*\[installed\]$'"
[ "$status" -eq 0 ]
[ ! "$output" = '' ]

run sh -c "printf \"$actual\" | grep -E '^rclone-.*\[installed\]$'"
[ "$status" -eq 0 ]
[ ! "$output" = '' ]
}

0 comments on commit 1fcf8d5

Please sign in to comment.