Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for an apt.conf override file #42

Merged
merged 1 commit into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,30 @@ When you deploy your project, the dokku-apt plugin will install according to you

The order of operations is:

1. `apt-env`
2. `apt-keys`
3. `apt-preferences`
4. `apt-sources-list`
5. `apt-repositories`
6. `apt-debconf`
7. `apt-packages`
8. `dpkg-packages`
1. `apt-conf`
2. `apt-env`
3. `apt-keys`
4. `apt-preferences`
5. `apt-sources-list`
6. `apt-repositories`
7. `apt-debconf`
8. `apt-packages`
9. `dpkg-packages`

Utilizing the above files, the base build image will be extended for further use in the build process. If an already extended app image that is compatible with the desired changes is found, then the above will be skipped in favor of using the pre-existing image.

Note that specifying packages within a `dpkg-packages` file will always bust the cache, as there is no way for the plugin to know if the files have changed between deploys.

### `apt-conf`

A config file for apt, as documented [here](https://linux.die.net/man/5/apt.conf). This is moved to the folder `/etc/apt/apt.conf.d/99dokku-apt`, and can override any `apt.conf` files that come before it in lexicographical order.

Example

```
Acquire::http::Proxy "http://user:password@proxy.example.com:8888/";
```

### `apt-env`

A file that can contain environment variables. Note that this is sourced, and should not contain arbitrary code.
Expand Down
9 changes: 7 additions & 2 deletions internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn-apt-fetch-sha() {
return
fi

APT_FILES=('apt-env' 'apt-keys' 'apt-preferences' 'apt-sources-list' 'apt-repositories' 'apt-debconf' 'apt-packages')
APT_FILES=('apt-conf' 'apt-env' 'apt-keys' 'apt-preferences' 'apt-sources-list' 'apt-repositories' 'apt-debconf' 'apt-packages')
for file in "${APT_FILES[@]}"; do
if [[ -f "$SOURCECODE_WORK_DIR/$file" ]]; then
INJECT_PACKAGES=true
Expand All @@ -47,7 +47,7 @@ fn-apt-populate-work-dir() {
declare SOURCECODE_WORK_DIR="$1" TMP_WORK_DIR="$2"
local APT_FILES file

APT_FILES=('apt-env' 'apt-keys' 'apt-preferences' 'apt-sources-list' 'apt-repositories' 'apt-debconf' 'apt-packages')
APT_FILES=('apt-conf' 'apt-env' 'apt-keys' 'apt-preferences' 'apt-sources-list' 'apt-repositories' 'apt-debconf' 'apt-packages')
for file in "${APT_FILES[@]}"; do
if [[ -f "$SOURCECODE_WORK_DIR/$file" ]]; then
cp "$SOURCECODE_WORK_DIR/$file" "$TMP_WORK_DIR/$file"
Expand All @@ -61,6 +61,11 @@ fn-apt-command() {
# $APP $DOKKU_IMAGE
sleep 2
export DEBIAN_FRONTEND=noninteractive
if [ -f $DIR/apt-conf ]; then
echo "-----> Copying apt-conf file into place"
mv -v $DIR/apt-conf /etc/apt/apt.conf.d/99dokku-apt
fi

if [ -f $DIR/apt-env ]; then
echo "-----> Sourcing apt env"
source $DIR/apt-env
Expand Down