Compare commits
146 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
767ba96186 | ||
|
|
55213e1045 | ||
|
|
1843d42e0b | ||
|
|
065f5e5922 | ||
|
|
f7beb3d95d | ||
|
|
c09dfb8ec8 | ||
|
|
87b90e96b6 | ||
|
|
e556be1a0d | ||
|
|
88fddf2a6d | ||
|
|
97fe71a829 | ||
|
|
988cdbd6bb | ||
|
|
be84325de1 | ||
|
|
e7d9d6b19e | ||
|
|
bd378e8a44 | ||
|
|
82da43cfba | ||
|
|
a96ad0c10c | ||
|
|
670e679a09 | ||
|
|
b03485a85b | ||
|
|
aac0408f76 | ||
|
|
5b9ed4f373 | ||
|
|
033b0952dd | ||
|
|
12e2686e3f | ||
|
|
cc2f054e6a | ||
|
|
a799630fac | ||
|
|
77f0f55ee7 | ||
|
|
48428ed777 | ||
|
|
0c7afb26b0 | ||
|
|
4f2c968daa | ||
|
|
411f0550e0 | ||
|
|
f9fcad257e | ||
|
|
b0d699f281 | ||
|
|
4e8242fe5e | ||
|
|
5ceccbdf68 | ||
|
|
324c08a8a2 | ||
|
|
103e47b6dd | ||
|
|
09831c3b93 | ||
|
|
99336870b8 | ||
|
|
c81e980fcf | ||
|
|
dbdf2ad55d | ||
|
|
9306011f70 | ||
|
|
162abcee4f | ||
|
|
c1ff3d4652 | ||
|
|
f9693e78c8 | ||
|
|
fe549f2fb5 | ||
|
|
d9300ad210 | ||
|
|
8ddf4888db | ||
|
|
bf5fbf4412 | ||
|
|
dfc98ecc0f | ||
|
|
86e53f96a9 | ||
|
|
3d4205b206 | ||
|
|
f81c802ecc | ||
|
|
5d9157bc40 | ||
|
|
6a85d6a58b | ||
|
|
8ddb214b0e | ||
|
|
308927adce | ||
|
|
7caa95b3f3 | ||
|
|
b5c85ad5be | ||
|
|
bad90b2b1d | ||
|
|
4c74e0dfba | ||
|
|
46933051b9 | ||
|
|
aeb9241d3b | ||
|
|
0d9b6b9852 | ||
|
|
5cac43fe55 | ||
|
|
8cc92680c5 | ||
|
|
b583f80221 | ||
|
|
6ab9f28d77 | ||
|
|
67c8af3869 | ||
|
|
12a9bdbf6e | ||
|
|
8c3fd77cfd | ||
|
|
9137be814c | ||
|
|
aad7f67f7c | ||
|
|
815b839eeb | ||
|
|
608f9d0333 | ||
|
|
ccbe2c719a | ||
|
|
76b36aa3f6 | ||
|
|
8c81d520f6 | ||
|
|
afe1e8b33c | ||
|
|
6eb0bd8c87 | ||
|
|
f3d53fbba4 | ||
|
|
b7ff627368 | ||
|
|
9ffddf3561 | ||
|
|
56ff76584d | ||
|
|
324d98d231 | ||
|
|
277e9691e1 | ||
|
|
bce0671057 | ||
|
|
ff10ef2c26 | ||
|
|
1d8a98e5ce | ||
|
|
cb43d0cc64 | ||
|
|
065bba5851 | ||
|
|
8efac2923b | ||
|
|
fc8c58a1e6 | ||
|
|
20b2773ea2 | ||
|
|
0bd7613da4 | ||
|
|
f7ef14d737 | ||
|
|
e00e498e50 | ||
|
|
17fb2ace91 | ||
|
|
2deb575961 | ||
|
|
a7465f9d81 | ||
|
|
9d55e37687 | ||
|
|
3c5a3fdd7c | ||
|
|
4477c92df9 | ||
|
|
a6062d4ab4 | ||
|
|
41f24a58b1 | ||
|
|
352900fcff | ||
|
|
62424633fc | ||
|
|
e2184a6f12 | ||
|
|
755cd909ed | ||
|
|
6338b368d4 | ||
|
|
ca56fa1b8b | ||
|
|
7c818eda47 | ||
|
|
bdb160bec1 | ||
|
|
7cd6f7666c | ||
|
|
2cdfa1cae1 | ||
|
|
cafbf44e2f | ||
|
|
cca507da6a | ||
|
|
d58fe853d6 | ||
|
|
03dc90b4fd | ||
|
|
2a4918c7ce | ||
|
|
7bb130edb7 | ||
|
|
3af1342a9b | ||
|
|
d16ff7fa12 | ||
|
|
d5dbd456ea | ||
|
|
3f25514e1a | ||
|
|
e3d0f693a7 | ||
|
|
97b33a9138 | ||
|
|
f73c927512 | ||
|
|
97750f8b28 | ||
|
|
827dbbc740 | ||
|
|
89e92749a6 | ||
|
|
e877a996be | ||
|
|
6bfbe0bb66 | ||
|
|
d728237697 | ||
|
|
279a706f78 | ||
|
|
dbd48356f5 | ||
|
|
6dc55624bd | ||
|
|
5e645e1489 | ||
|
|
87a786fec5 | ||
|
|
c9fc203596 | ||
|
|
f87525d8cf | ||
|
|
df4dbe5d88 | ||
|
|
31332a5061 | ||
|
|
1a66102e30 | ||
|
|
8c0380beec | ||
|
|
a7ef06028e | ||
|
|
c80fcf7b8e | ||
|
|
7115839fd5 |
@@ -1,116 +1,13 @@
|
||||
version: 2.1
|
||||
|
||||
commands:
|
||||
init-tests:
|
||||
description: "Setup dokku for testing"
|
||||
steps:
|
||||
- checkout
|
||||
- attach_workspace:
|
||||
at: /home/circleci/project
|
||||
- run:
|
||||
name: resolve dokku.me
|
||||
command: |
|
||||
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to ens4
|
||||
# this is maybe eth0 on github
|
||||
ifconfig
|
||||
sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev ens4
|
||||
- run:
|
||||
name: install ci-dependencies
|
||||
command: make ci-dependencies
|
||||
- run:
|
||||
name: setup tests
|
||||
command: ./tests/ci/setup.sh
|
||||
- run:
|
||||
name: dokku cleanup:skip
|
||||
command: echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup
|
||||
- run:
|
||||
name: dokku report
|
||||
command: dokku report
|
||||
|
||||
executors:
|
||||
default:
|
||||
machine:
|
||||
image: ubuntu-1604:201903-01
|
||||
working_directory: /home/circleci/project
|
||||
|
||||
jobs:
|
||||
build:
|
||||
executor: default
|
||||
noop:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: build package
|
||||
command: ./tests/ci/setup.sh build
|
||||
- persist_to_workspace:
|
||||
root: /home/circleci/project
|
||||
paths:
|
||||
- build
|
||||
- store_artifacts:
|
||||
path: /home/circleci/project/build/dokku.deb
|
||||
- store_artifacts:
|
||||
path: /home/circleci/project/build/dokku.rpm
|
||||
docker-deploy-tests:
|
||||
executor: default
|
||||
steps:
|
||||
- init-tests
|
||||
- run:
|
||||
name: run docker deploy tests
|
||||
shell: /bin/bash
|
||||
no_output_timeout: 20
|
||||
command: |
|
||||
./tests/ci/setup.sh docker
|
||||
DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker
|
||||
go-tests:
|
||||
executor: default
|
||||
parallelism: 4
|
||||
steps:
|
||||
- init-tests
|
||||
- run:
|
||||
name: run go tests
|
||||
command: |
|
||||
case $CIRCLE_NODE_INDEX in
|
||||
0) sudo -E make -e lint-ci go-tests ci-go-coverage ;;
|
||||
1) sudo -E make -e deploy-test-checks-root deploy-test-config ;;
|
||||
2) sudo -E make -e deploy-test-multi ;;
|
||||
3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;;
|
||||
esac
|
||||
- store_artifacts:
|
||||
path: ./coverage.out
|
||||
test:
|
||||
executor: default
|
||||
parallelism: 4
|
||||
steps:
|
||||
- init-tests
|
||||
- run:
|
||||
name: run bats tests
|
||||
command: |
|
||||
if ! sudo -E make -e test-ci; then
|
||||
sudo -E make tests-ci-retry-failed
|
||||
fi
|
||||
no_output_timeout: 60m
|
||||
shell: /bin/bash
|
||||
- run:
|
||||
name: output oomkills
|
||||
command: cat /var/log/syslog
|
||||
when: on_fail
|
||||
- store_artifacts:
|
||||
path: ./test-results
|
||||
destination: test-results
|
||||
- store_test_results:
|
||||
path: test-results
|
||||
- run: echo "this is a noop"
|
||||
|
||||
workflows:
|
||||
workflow:
|
||||
noop:
|
||||
jobs:
|
||||
- build
|
||||
- docker-deploy-tests:
|
||||
requires:
|
||||
- build
|
||||
- test
|
||||
- go-tests:
|
||||
requires:
|
||||
- build
|
||||
- test:
|
||||
requires:
|
||||
- build
|
||||
- go-tests
|
||||
- noop
|
||||
|
||||
15
.github/commands/ci-run
vendored
Executable file
15
.github/commands/ci-run
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
main() {
|
||||
declare FILE_NAME="$1"
|
||||
|
||||
mkdir -p test-results/bats
|
||||
pushd tests/unit >/dev/null
|
||||
bats --report-formatter junit --output ../../test-results/bats "$FILE_NAME.bats"
|
||||
popd >/dev/null
|
||||
|
||||
ls -lah test-results/bats
|
||||
}
|
||||
|
||||
main "$@"
|
||||
28
.github/commands/ci-setup
vendored
Executable file
28
.github/commands/ci-setup
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
echo "=====> set hostname"
|
||||
hostname
|
||||
internal_ip="$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')"
|
||||
sudo hostname "dokku.me"
|
||||
echo "dokku.me" | sudo tee /etc/hostname
|
||||
hostname
|
||||
sudo cat /etc/hostname
|
||||
|
||||
echo "=====> resolve dokku.me"
|
||||
sudo apt -qq -y --no-install-recommends install net-tools
|
||||
# dokku.me now resolves to 10.0.0.2. add 10.0.0.2/24 to eth0
|
||||
ifconfig
|
||||
sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth0
|
||||
|
||||
echo "=====> install ci-dependencies"
|
||||
make ci-dependencies
|
||||
|
||||
echo "=====> setup tests"
|
||||
./tests/ci/setup.sh
|
||||
|
||||
echo "=====> dokku cleanup:skip"
|
||||
echo 'export DOKKU_SKIP_CLEANUP=true' | sudo tee /home/dokku/.dokkurc/dokku_skip_cleanup
|
||||
|
||||
echo "=====> dokku report"
|
||||
dokku report
|
||||
9
.github/commands/matrix
vendored
Executable file
9
.github/commands/matrix
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import os
|
||||
|
||||
keys = ["index"]
|
||||
values = [[s.replace(".bats", "") for s in os.listdir("tests/unit/") if s.endswith(".bats")]]
|
||||
zi = zip(keys, values)
|
||||
data = json.dumps(dict(zi))
|
||||
print(data.replace(" ", ""))
|
||||
157
.github/workflows/ci.yml
vendored
Normal file
157
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- '*'
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build
|
||||
runs-on: ubuntu-16.04
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: build package
|
||||
run: ./tests/ci/setup.sh build
|
||||
|
||||
- name: set matrix for build
|
||||
id: set-matrix
|
||||
run: |
|
||||
json=$(python .github/commands/matrix)
|
||||
echo $json
|
||||
echo "::set-output name=matrix::$(echo "$json")"
|
||||
|
||||
- name: upload packages
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: build
|
||||
path: build
|
||||
|
||||
unit-tests:
|
||||
name: unit.${{ matrix.index }}
|
||||
needs: build
|
||||
runs-on: ubuntu-16.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{fromJson(needs.build.outputs.matrix)}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: download packages
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: build
|
||||
|
||||
- name: ci-setup
|
||||
run: ./.github/commands/ci-setup
|
||||
|
||||
# - name: start ssh session
|
||||
# uses: luchihoratiu/debug-via-ssh@main
|
||||
# with:
|
||||
# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
|
||||
# SSH_PASS: ${{ secrets.SSH_PASS }}
|
||||
|
||||
- name: run ci
|
||||
timeout-minutes: 30
|
||||
run: sudo -E ./.github/commands/ci-run ${{ matrix.index }}
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: test-results-${{ matrix.index }}
|
||||
path: test-results
|
||||
|
||||
docker-deploy-tests:
|
||||
name: docker
|
||||
needs: build
|
||||
runs-on: ubuntu-16.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: download packages
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: build
|
||||
|
||||
- name: ci-setup
|
||||
run: ./.github/commands/ci-setup
|
||||
|
||||
- name: test docker deploys
|
||||
shell: bash
|
||||
timeout-minutes: 20
|
||||
run: |
|
||||
./tests/ci/setup.sh docker
|
||||
DOKKU_SSH_PORT=3022 sudo -E make -e test-ci-docker
|
||||
|
||||
go-tests:
|
||||
name: go.${{ matrix.index }}
|
||||
needs: build
|
||||
runs-on: ubuntu-16.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
index: [0, 1, 2, 3]
|
||||
env:
|
||||
GITHUB_NODE_INDEX: ${{ matrix.index }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: download packages
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: build
|
||||
|
||||
- name: ci-setup
|
||||
run: ./.github/commands/ci-setup
|
||||
|
||||
- name: run go tests
|
||||
run: |
|
||||
export CIRCLE_SHA1=$GITHUB_SHA
|
||||
echo "CODACY_TOKEN=$CODACY_TOKEN"
|
||||
if [ "$CODACY_TOKEN" != "" ]; then
|
||||
echo "Detected value for CODACY_TOKEN"
|
||||
fi
|
||||
case $GITHUB_NODE_INDEX in
|
||||
0) sudo -E make -e lint-ci go-tests ci-go-coverage ;;
|
||||
1) sudo -E make -e deploy-test-checks-root deploy-test-config ;;
|
||||
2) sudo -E make -e deploy-test-multi ;;
|
||||
3) sudo -E make -e deploy-test-go-fail-predeploy deploy-test-go-fail-postdeploy ;;
|
||||
esac
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: coverage.${{ matrix.index }}
|
||||
path: test-results/coverage
|
||||
|
||||
publish-test-results:
|
||||
name: publish-test-results
|
||||
needs: unit-tests
|
||||
runs-on: ubuntu-16.04
|
||||
# the build-and-test job might be skipped, we don't need to run this job then
|
||||
if: success() || failure()
|
||||
|
||||
steps:
|
||||
- name: download test-results
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
path: test-results
|
||||
|
||||
- name: Publish Unit Test Results
|
||||
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1.6
|
||||
with:
|
||||
check_name: Unit Test Results
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: test-results/**/*.xml
|
||||
comment_on_pr: false
|
||||
@@ -5,7 +5,7 @@ several ways to help out:
|
||||
|
||||
* Create an [issue](https://github.com/dokku/dokku/issues) on GitHub, if you
|
||||
have found a bug
|
||||
* Write test cases for open bug issues
|
||||
* Write [test cases](http://dokku.viewdocs.io/dokku/development/testing/) for open bug issues
|
||||
* Write patches for open bug/feature issues, preferably with test cases
|
||||
included
|
||||
* Contribute to the [documentation](http://dokku.viewdocs.io/dokku/)
|
||||
@@ -25,7 +25,7 @@ a chance of keeping on top of things.
|
||||
* [Which branch to base the work](#which-branch-to-base-the-work)
|
||||
* [Submitting Changes](#submitting-changes)
|
||||
* [When will my change be merged?](#when-will-my-change-be-merged)
|
||||
* [Test cases and codesniffs](#test-cases-and-codesniffs)
|
||||
* [Running tests locally](#running-tests-locally)
|
||||
* [Additional Resources](#additional-resources)
|
||||
|
||||
## Reporting security issues
|
||||
@@ -127,21 +127,10 @@ requests:
|
||||
- backwards incompatible change (minor)
|
||||
- major feature (minor)
|
||||
|
||||
### Test cases and codesniffs
|
||||
### Running tests locally
|
||||
|
||||
Dokku tests require [bats](https://github.com/sstephenson/bats).
|
||||
To run the test cases locally use the following command:
|
||||
|
||||
make ci-dependencies
|
||||
make unit-tests deploy-tests
|
||||
|
||||
To run the shellcheck sniffs for Dokku coding standards:
|
||||
|
||||
make ci-dependencies
|
||||
make lint
|
||||
|
||||
The [testing docs](http://dokku.viewdocs.io/dokku/development/testing/)
|
||||
contains installation info for bats and shellcheck.
|
||||
Please read the [testing docs](http://dokku.viewdocs.io/dokku/development/testing/),
|
||||
which contains test setup information as well as tips for running tests.
|
||||
|
||||
# Additional Resources
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ RUN echo "dokku dokku/hostname string $DOKKU_HOSTNAME" | debconf-set-selections
|
||||
&& cp /tmp/dhparam.pem /etc/nginx/dhparam.pem \
|
||||
&& apt-get update -qq \
|
||||
&& apt-get upgrade -qq -y \
|
||||
&& apt-get -qq -y --no-install-recommends install --only-upgrade openssl openssh-server \
|
||||
&& apt-get -qq -y --no-install-recommends --only-upgrade install openssl openssh-server \
|
||||
&& apt-get -qq -y --no-install-recommends install rsync /tmp/dokku.deb \
|
||||
&& apt-get purge -qq -y syslog-ng-core \
|
||||
&& apt-get autoremove -qq -y \
|
||||
|
||||
112
HISTORY.md
112
HISTORY.md
@@ -1,5 +1,117 @@
|
||||
# History
|
||||
|
||||
## 0.23.2
|
||||
|
||||
Install/update via the bootstrap script:
|
||||
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.23.2/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.23.2 bash bootstrap.sh
|
||||
```
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- #4388: @josegonzalez Do not inject max-size option when not using local or json-file log-drivers
|
||||
- #4386: @josegonzalez Update to docker-image-labeler that handles in-use images
|
||||
|
||||
### New Features
|
||||
|
||||
- #4387: @josegonzalez Only warn if the vector container is stopped when fetching logs
|
||||
- #4372: @josegonzalez Add ability to clear an individual resource
|
||||
- #4384: @josegonzalez Add support for injected cron entries from external plugins
|
||||
|
||||
### Refactors
|
||||
|
||||
- #4373: @josegonzalez Do not attempt to extract Procfile in ps:scale
|
||||
|
||||
### Documentation
|
||||
|
||||
- #4377: @josegonzalez Add note about the dokku user cron being overwritten by Dokku
|
||||
|
||||
### Other
|
||||
|
||||
- #3757: @pickettd Add provision line to Windows Vagrant box for dokku-installer
|
||||
|
||||
## 0.23.1
|
||||
|
||||
Install/update via the bootstrap script:
|
||||
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.23.1/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.23.1 bash bootstrap.sh
|
||||
```
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- #4368: @josegonzalez Always report resources
|
||||
|
||||
### New Features
|
||||
|
||||
- #4369: @josegonzalez Allow formatting :report command output as json
|
||||
|
||||
### Documentation
|
||||
|
||||
- #4367: @josegonzalez Update deeplink to digitalocean marketplace image on homepage
|
||||
- #4366: @josegonzalez Update Digitalocean docs
|
||||
- #4363: @josegonzalez Refer to the monitored slack and github discussions channels in the issue template
|
||||
- #4359: @josegonzalez Fix command call for set-property
|
||||
- #4358: @Cellane Update header on cron documentation
|
||||
- #4357: @Cellane Fix spelling in nginx documentation
|
||||
|
||||
### Other
|
||||
|
||||
- #4365: @dependabot-preview[bot] chore(deps): bump jinja2 from 2.11.2 to 2.11.3 in /tests/apps/python-flask
|
||||
|
||||
## 0.23.0
|
||||
|
||||
Install/update via the bootstrap script:
|
||||
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.23.0/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.23.0 bash bootstrap.sh
|
||||
```
|
||||
|
||||
See the [0.23.0 migration guide](/docs/appendices/0.23.0-migration-guide.md) for more information on migrating to 0.23.0.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- #4356: @josegonzalez Do not retag images unnecessarily
|
||||
- #4355: @josegonzalez Allow underscores in vector schemes
|
||||
- #4350: @josegonzalez Add missing trigger to events plugin
|
||||
- #4348: @josegonzalez Correct app-specific shell handling
|
||||
- #4333: @josegonzalez Drop tmpdir environment variables when not running as dokku user
|
||||
|
||||
### New Features
|
||||
|
||||
- #4336: @josegonzalez Add ability to manage stacks on an app or global level …
|
||||
- #4354: @josegonzalez Log all triggers called by golang in trace output
|
||||
- #4300: @AubreyHewes allow disabling hsts globally and explicitly enable per app
|
||||
- #4337: @josegonzalez Add logrotation to container log files
|
||||
- #4318: @josegonzalez Add ability to set client max body size via nginx:set
|
||||
- #4343: @josegonzalez feat: add initial scheduled task implementation
|
||||
- #4297: @josegonzalez Add support for cloning/syncing from a remote repository
|
||||
- #4340: @bjornpost Allow configuring x-forwarded-* proxy headers via nginx:set
|
||||
|
||||
### Refactors
|
||||
|
||||
- #4349: @josegonzalez Remove need for internal dokku calls
|
||||
|
||||
### Documentation
|
||||
|
||||
- #4347: @fomojola Add post-deploy webhook to list of community plugins
|
||||
- #4342: @AubreyHewes Point to current testing docs
|
||||
- #4341: @josegonzalez Add testing link to contributing.md
|
||||
|
||||
### Tests
|
||||
|
||||
- #4352: @josegonzalez Add a test for application renames
|
||||
- #4351: @josegonzalez Set hostname for CI runs
|
||||
- #4322: @josegonzalez Switch to Github Actions for CI
|
||||
|
||||
### Other
|
||||
|
||||
- #4353: @josegonzalez Drop unused flag introduced by logs max-size feature
|
||||
|
||||
## 0.22.9
|
||||
|
||||
Install/update via the bootstrap script:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
>
|
||||
> If you'd like to sponsor specific functionality, see the project's [Sponsoring](https://github.com/dokku/.github/blob/master/SPONSORING.md) document.
|
||||
>
|
||||
> If you need help figuring out how to use a specific buildpack, or are having issues using multiple buildpacks, please see our [irc or slack channels](http://dokku.viewdocs.io/dokku/getting-started/where-to-get-help/#the-irc-and-slack-channels). Issues pertaining to buildpacks may be closed and locked.
|
||||
> If you need help figuring out how to use a specific buildpack, are seeing an issue in during the buildpack process, or are having issues using multiple buildpacks, please see our [slack channels or github discussion board](http://dokku.viewdocs.io/dokku/getting-started/where-to-get-help/#monitored-locations). Issues pertaining to buildpacks may be closed and locked.
|
||||
>
|
||||
> If you need support for a version of Dokku that is more than a year old, your issue may be closed without an answer. Please upgrade to a recent version.
|
||||
|
||||
|
||||
16
Makefile
16
Makefile
@@ -1,14 +1,16 @@
|
||||
DOKKU_VERSION ?= master
|
||||
|
||||
DOCKER_IMAGE_LABELER_VERSION ?= 0.2.2
|
||||
HEROKUISH_VERSION ?= 0.5.19
|
||||
PROCFILE_VERSION ?= 0.11.0
|
||||
PLUGN_VERSION ?= 0.6.1
|
||||
PROCFILE_VERSION ?= 0.11.0
|
||||
SIGIL_VERSION ?= 0.6.0
|
||||
SSHCOMMAND_VERSION ?= 0.12.0
|
||||
SSHCOMMAND_URL ?= https://github.com/dokku/sshcommand/releases/download/v${SSHCOMMAND_VERSION}/sshcommand_${SSHCOMMAND_VERSION}_linux_x86_64.tgz
|
||||
PROCFILE_UTIL_URL ?= https://github.com/josegonzalez/go-procfile-util/releases/download/v${PROCFILE_VERSION}/procfile-util_${PROCFILE_VERSION}_linux_x86_64.tgz
|
||||
DOCKER_IMAGE_LABELER_URL ?= https://github.com/dokku/docker-image-labeler/releases/download/v${DOCKER_IMAGE_LABELER_VERSION}/docker-image-labeler_${DOCKER_IMAGE_LABELER_VERSION}_linux_x86_64.tgz
|
||||
PLUGN_URL ?= https://github.com/dokku/plugn/releases/download/v${PLUGN_VERSION}/plugn_${PLUGN_VERSION}_linux_x86_64.tgz
|
||||
PROCFILE_UTIL_URL ?= https://github.com/josegonzalez/go-procfile-util/releases/download/v${PROCFILE_VERSION}/procfile-util_${PROCFILE_VERSION}_linux_x86_64.tgz
|
||||
SIGIL_URL ?= https://github.com/gliderlabs/sigil/releases/download/v${SIGIL_VERSION}/sigil_${SIGIL_VERSION}_Linux_x86_64.tgz
|
||||
SSHCOMMAND_URL ?= https://github.com/dokku/sshcommand/releases/download/v${SSHCOMMAND_VERSION}/sshcommand_${SSHCOMMAND_VERSION}_linux_x86_64.tgz
|
||||
STACK_URL ?= https://github.com/gliderlabs/herokuish.git
|
||||
PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest
|
||||
DOKKU_LIB_ROOT ?= /var/lib/dokku
|
||||
@@ -32,7 +34,7 @@ endif
|
||||
|
||||
include common.mk
|
||||
|
||||
.PHONY: all apt-update install version copyfiles copyplugin man-db plugins dependencies sshcommand procfile-util plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build
|
||||
.PHONY: all apt-update install version copyfiles copyplugin man-db plugins dependencies docker-image-labeler sshcommand procfile-util plugn docker aufs stack count dokku-installer vagrant-acl-add vagrant-dokku go-build
|
||||
|
||||
include tests.mk
|
||||
include package.mk
|
||||
@@ -123,7 +125,7 @@ plugin-dependencies: plugn procfile-util
|
||||
plugins: plugn procfile-util docker
|
||||
sudo -E dokku plugin:install --core
|
||||
|
||||
dependencies: apt-update sshcommand plugn procfile-util docker help2man man-db sigil dos2unix jq
|
||||
dependencies: apt-update docker-image-labeler sshcommand plugn procfile-util docker help2man man-db sigil dos2unix jq
|
||||
$(MAKE) -e stack
|
||||
|
||||
apt-update:
|
||||
@@ -141,6 +143,10 @@ help2man:
|
||||
man-db:
|
||||
apt-get -qq -y --no-install-recommends install man-db
|
||||
|
||||
docker-image-labeler:
|
||||
wget -qO /tmp/docker-image-labeler_latest.tgz ${DOCKER_IMAGE_LABELER_URL}
|
||||
tar xzf /tmp/docker-image-labeler_latest.tgz -C /usr/local/bin
|
||||
|
||||
sshcommand:
|
||||
wget -qO /tmp/sshcommand_latest.tgz ${SSHCOMMAND_URL}
|
||||
tar xzf /tmp/sshcommand_latest.tgz -C /usr/local/bin
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Dokku
|
||||
[](https://circleci.com/gh/dokku/dokku/tree/master)
|
||||
[](https://github.com/dokku/dokku/actions?query=workflow%3ACI)
|
||||
[](https://packagecloud.io/dokku/dokku)
|
||||
[](https://aur.archlinux.org/packages/dokku/)
|
||||
[](https://webchat.freenode.net/?channels=dokku)
|
||||
@@ -99,8 +99,8 @@ Otherwise, you will need to import the keypair manually after installation using
|
||||
To install the latest stable release, run the following commands as a user who has access to `sudo`:
|
||||
|
||||
```shell
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.22.9/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.22.9 bash bootstrap.sh
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.23.2/bootstrap.sh
|
||||
sudo DOKKU_TAG=v0.23.2 bash bootstrap.sh
|
||||
```
|
||||
|
||||
You can then proceed to the ip address or domain name associated with your server to complete the web-based installation.
|
||||
|
||||
1
Vagrantfile
vendored
1
Vagrantfile
vendored
@@ -74,6 +74,7 @@ Vagrant::configure("2") do |config|
|
||||
vm.vm.network :private_network, ip: DOKKU_IP
|
||||
vm.vm.provision :shell, :inline => "export DEBIAN_FRONTEND=noninteractive && apt-get update -qq >/dev/null && apt-get -qq -y --no-install-recommends install git dos2unix >/dev/null"
|
||||
vm.vm.provision :shell, :inline => "cd /vagrant/ && export DOKKU_BRANCH=`git symbolic-ref -q --short HEAD 2>/dev/null` && export DOKKU_TAG=`git describe --tags --exact-match 2>/dev/null` && cd /root/ && cp /vagrant/bootstrap.sh ./ && dos2unix bootstrap.sh && bash bootstrap.sh"
|
||||
vm.vm.provision :shell, :inline => "cd /root/dokku && make dokku-installer"
|
||||
end
|
||||
|
||||
config.vm.define "dokku-deb", autostart: false do |vm|
|
||||
|
||||
@@ -2,6 +2,8 @@ GO_ARGS ?=
|
||||
GO_PLUGIN_MAKE_TARGET ?= build
|
||||
GO_REPO_ROOT := /go/src/github.com/dokku/dokku
|
||||
BUILD_IMAGE := golang:1.15.6
|
||||
GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache
|
||||
GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod
|
||||
|
||||
.PHONY: build-in-docker build clean src-clean
|
||||
|
||||
@@ -11,7 +13,8 @@ build-in-docker: clean
|
||||
mkdir -p /tmp/dokku-go-build-cache
|
||||
docker run --rm \
|
||||
-v $$PWD/../..:$(GO_REPO_ROOT) \
|
||||
-v /tmp/dokku-go-build-cache:/root/.cache \
|
||||
-v $(GO_BUILD_CACHE):/root/.cache \
|
||||
-v $(GO_MOD_CACHE):/go/pkg/mod \
|
||||
-e PLUGIN_NAME=$(PLUGIN_NAME) \
|
||||
-e GO111MODULE=on \
|
||||
-w $(GO_REPO_ROOT)/plugins/$(PLUGIN_NAME) \
|
||||
|
||||
@@ -15,7 +15,7 @@ import subprocess
|
||||
import sys
|
||||
import threading
|
||||
|
||||
VERSION = 'v0.22.9'
|
||||
VERSION = 'v0.23.2'
|
||||
|
||||
def bytes_to_string(b):
|
||||
if type(b) == bytes:
|
||||
|
||||
4
debian/control
vendored
4
debian/control
vendored
@@ -1,9 +1,9 @@
|
||||
Package: dokku
|
||||
Version: 0.22.9
|
||||
Version: 0.23.2
|
||||
Section: web
|
||||
Priority: optional
|
||||
Architecture: amd64
|
||||
Depends: locales, git, cpio, curl, man-db, netcat, sshcommand (>= 0.12.0), docker-engine-cs (>= 17.05.0) | docker-engine (>= 17.05.0) | docker-io (>= 17.05.0) | docker.io (>= 17.05.0) | docker-ce (>= 17.05.0) | docker-ee (>= 17.05.0) | moby-engine, net-tools, software-properties-common, procfile-util (>= 0.11.0), python-software-properties | python3-software-properties, rsyslog, dos2unix, jq
|
||||
Depends: locales, git, cpio, curl, man-db, netcat, sshcommand (>= 0.12.0), docker-engine-cs (>= 17.05.0) | docker-engine (>= 17.05.0) | docker-io (>= 17.05.0) | docker.io (>= 17.05.0) | docker-ce (>= 17.05.0) | docker-ee (>= 17.05.0) | moby-engine, docker-image-labeler (>= 0.2.2), net-tools, software-properties-common, procfile-util (>= 0.11.0), python-software-properties | python3-software-properties, rsyslog, dos2unix, jq
|
||||
Recommends: herokuish (>= 0.3.4), parallel, dokku-update, dokku-event-listener
|
||||
Pre-Depends: gliderlabs-sigil, nginx (>= 1.8.0) | openresty, dnsutils, cgroupfs-mount | cgroup-lite, plugn (>= 0.3.0), sudo, python3, debconf
|
||||
Maintainer: Jose Diaz-Gonzalez <dokku@josediazgonzalez.com>
|
||||
|
||||
@@ -1 +1 @@
|
||||
dokku ALL=NOPASSWD:SETENV:/usr/bin/docker
|
||||
dokku ALL=NOPASSWD:SETENV:/usr/bin/docker,/usr/bin/docker-image-labeler
|
||||
|
||||
20
docker/usr/local/bin/docker-image-labeler
Executable file
20
docker/usr/local/bin/docker-image-labeler
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
[[ $TRACE ]] && set -x
|
||||
|
||||
main() {
|
||||
declare desc="re-runs docker-image-labeler commands as sudo"
|
||||
local DOCKER_IMAGE_LABELER_BIN=""
|
||||
if [[ -x "/usr/bin/docker-image-labeler" ]]; then
|
||||
DOCKER_IMAGE_LABELER_BIN="/usr/bin/docker-image-labeler"
|
||||
fi
|
||||
|
||||
if [[ -z "$DOCKER_IMAGE_LABELER_BIN" ]]; then
|
||||
echo "! No docker-image-labeler binary found" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo -E "$DOCKER_IMAGE_LABELER_BIN" "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -35,35 +35,35 @@ dokku plugin:list
|
||||
|
||||
```
|
||||
plugn: dev
|
||||
00_dokku-standard 0.22.9 enabled dokku core standard plugin
|
||||
20_events 0.22.9 enabled dokku core events logging plugin
|
||||
app-json 0.22.9 enabled dokku core app-json plugin
|
||||
apps 0.22.9 enabled dokku core apps plugin
|
||||
build-env 0.22.9 enabled dokku core build-env plugin
|
||||
buildpacks 0.22.9 enabled dokku core buildpacks plugin
|
||||
certs 0.22.9 enabled dokku core certificate management plugin
|
||||
checks 0.22.9 enabled dokku core checks plugin
|
||||
common 0.22.9 enabled dokku core common plugin
|
||||
config 0.22.9 enabled dokku core config plugin
|
||||
docker-options 0.22.9 enabled dokku core docker-options plugin
|
||||
domains 0.22.9 enabled dokku core domains plugin
|
||||
enter 0.22.9 enabled dokku core enter plugin
|
||||
git 0.22.9 enabled dokku core git plugin
|
||||
logs 0.22.9 enabled dokku core logs plugin
|
||||
network 0.22.9 enabled dokku core network plugin
|
||||
nginx-vhosts 0.22.9 enabled dokku core nginx-vhosts plugin
|
||||
plugin 0.22.9 enabled dokku core plugin plugin
|
||||
proxy 0.22.9 enabled dokku core proxy plugin
|
||||
ps 0.22.9 enabled dokku core ps plugin
|
||||
repo 0.22.9 enabled dokku core repo plugin
|
||||
resource 0.22.9 enabled dokku core resource plugin
|
||||
scheduler-docker-local 0.22.9 enabled dokku core scheduler-docker-local plugin
|
||||
shell 0.22.9 enabled dokku core shell plugin
|
||||
ssh-keys 0.22.9 enabled dokku core ssh-keys plugin
|
||||
storage 0.22.9 enabled dokku core storage plugin
|
||||
tags 0.22.9 enabled dokku core tags plugin
|
||||
tar 0.22.9 enabled dokku core tar plugin
|
||||
trace 0.22.9 enabled dokku core trace plugin
|
||||
00_dokku-standard 0.23.2 enabled dokku core standard plugin
|
||||
20_events 0.23.2 enabled dokku core events logging plugin
|
||||
app-json 0.23.2 enabled dokku core app-json plugin
|
||||
apps 0.23.2 enabled dokku core apps plugin
|
||||
build-env 0.23.2 enabled dokku core build-env plugin
|
||||
buildpacks 0.23.2 enabled dokku core buildpacks plugin
|
||||
certs 0.23.2 enabled dokku core certificate management plugin
|
||||
checks 0.23.2 enabled dokku core checks plugin
|
||||
common 0.23.2 enabled dokku core common plugin
|
||||
config 0.23.2 enabled dokku core config plugin
|
||||
docker-options 0.23.2 enabled dokku core docker-options plugin
|
||||
domains 0.23.2 enabled dokku core domains plugin
|
||||
enter 0.23.2 enabled dokku core enter plugin
|
||||
git 0.23.2 enabled dokku core git plugin
|
||||
logs 0.23.2 enabled dokku core logs plugin
|
||||
network 0.23.2 enabled dokku core network plugin
|
||||
nginx-vhosts 0.23.2 enabled dokku core nginx-vhosts plugin
|
||||
plugin 0.23.2 enabled dokku core plugin plugin
|
||||
proxy 0.23.2 enabled dokku core proxy plugin
|
||||
ps 0.23.2 enabled dokku core ps plugin
|
||||
repo 0.23.2 enabled dokku core repo plugin
|
||||
resource 0.23.2 enabled dokku core resource plugin
|
||||
scheduler-docker-local 0.23.2 enabled dokku core scheduler-docker-local plugin
|
||||
shell 0.23.2 enabled dokku core shell plugin
|
||||
ssh-keys 0.23.2 enabled dokku core ssh-keys plugin
|
||||
storage 0.23.2 enabled dokku core storage plugin
|
||||
tags 0.23.2 enabled dokku core tags plugin
|
||||
tar 0.23.2 enabled dokku core tar plugin
|
||||
trace 0.23.2 enabled dokku core trace plugin
|
||||
```
|
||||
|
||||
> Warning: All plugin commands other than `plugin:list` and `plugin:help` require sudo access and must be run directly from the Dokku server.
|
||||
|
||||
@@ -71,6 +71,17 @@ dokku resource:limit --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
A resource value can be individually cleared by setting the value to the special value `clear`.
|
||||
|
||||
```shell
|
||||
dokku resource:limit --cpu clear node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting resource limits for node-js-app
|
||||
cpu: cleared
|
||||
```
|
||||
|
||||
#### Displaying Resource Limits
|
||||
|
||||
Running the `resource:limit` command without any flags will display the currently configured default app limits.
|
||||
@@ -169,6 +180,17 @@ dokku resource:reserve --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
A resource value can be individually cleared by setting the value to the special value `clear`.
|
||||
|
||||
```shell
|
||||
dokku resource:reserve --cpu clear node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting resource reservation for node-js-app
|
||||
cpu: cleared
|
||||
```
|
||||
|
||||
#### Displaying Resource Reservations
|
||||
|
||||
Running the `resource:reserve` command without any flags will display the currently configured default app reservations.
|
||||
|
||||
8
docs/appendices/0.23.0-migration-guide.md
Normal file
8
docs/appendices/0.23.0-migration-guide.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# 0.23.0 Migration Guide
|
||||
|
||||
## Changes
|
||||
|
||||
- The `plugin:list` command no longer outputs the version for the `plugn` binary.
|
||||
- Users building docker images that run Dokku will need to use a new sudoer wrapper for the `docker-image-labeler` binary to work correctly. A reference version has been placed in the `docker` skeleton directory. This should only impact platform developers, and users of our Docker image will already have the file available.
|
||||
- The `dokku` user's cron is now in use by Dokku itself. Customizations will be overwritten. Users are encouraged to use a cron entry in `/etc/cron.d/dokku` to avoid this issue.
|
||||
- As of 0.23.0, Dokku will now inject the `max-size` log driver option for applications. This is restricted to app-configured log driver values empty, `local` or `json-file` in 0.23.1 to increase setup compatibility. Users who configure alternative log drivers at the system level will need to either set the global `max-size` property to `unlimited` or switch to the built-in `vector` logging support.
|
||||
@@ -2,10 +2,10 @@
|
||||
<browserconfig>
|
||||
<msapplication>
|
||||
<tile>
|
||||
<square70x70logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-70x70.png"/>
|
||||
<square150x150logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-150x150.png"/>
|
||||
<square310x310logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-310x310.png"/>
|
||||
<wide310x150logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-310x150.png"/>
|
||||
<square70x70logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-70x70.png"/>
|
||||
<square150x150logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-150x150.png"/>
|
||||
<square310x310logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-310x310.png"/>
|
||||
<wide310x150logo src="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-310x150.png"/>
|
||||
<TileColor>#da532c</TileColor>
|
||||
</tile>
|
||||
</msapplication>
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
"name": "Dokku",
|
||||
"icons": [
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-36x36.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-36x36.png",
|
||||
"sizes": "36x36",
|
||||
"type": "image\/png",
|
||||
"density": "0.75"
|
||||
},
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-48x48.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-48x48.png",
|
||||
"sizes": "48x48",
|
||||
"type": "image\/png",
|
||||
"density": "1.0"
|
||||
},
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-72x72.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image\/png",
|
||||
"density": "1.5"
|
||||
},
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-96x96.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image\/png",
|
||||
"density": "2.0"
|
||||
},
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-144x144.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image\/png",
|
||||
"density": "3.0"
|
||||
},
|
||||
{
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.22.9\/docs\/assets\/favicons\/android-chrome-192x192.png",
|
||||
"src": "https:\/\/cdn.jsdelivr.net\/dokku\/dokku@v0.23.2\/docs\/assets\/favicons\/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image\/png",
|
||||
"density": "4.0"
|
||||
|
||||
@@ -39,13 +39,13 @@ h1 {
|
||||
font-size: 1.6em;
|
||||
}
|
||||
.header .navbar-brand a {
|
||||
background-image: url(https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/dokku.png);
|
||||
background-image: url(https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/dokku.png);
|
||||
text-indent: 40px;
|
||||
}
|
||||
.blurb {
|
||||
color: #424242;
|
||||
background-color: #ededed;
|
||||
background-image: url(https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/gplaypattern.png);
|
||||
background-image: url(https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/gplaypattern.png);
|
||||
padding: 45px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
"0.19.13",
|
||||
"0.20.4",
|
||||
"0.21.4",
|
||||
"0.22.9"
|
||||
"0.22.9",
|
||||
"0.23.2"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ The following plugins are available and provided by Dokku maintainers. Please f
|
||||
| [Application build hook](https://github.com/fteychene/dokku-build-hook) | [fteychene][] | 0.4.0+ |
|
||||
| [Post Deploy Script](https://github.com/baikunz/dokku-post-deploy-script) | [baikunz][] | 0.4.0+ |
|
||||
| [Auto Sync](https://github.com/IdeaSynthesis/dokku-autosync)<sup>4</sup> | [fomojola][] | 0.8.1+ |
|
||||
| [Deploy Webhook](https://github.com/IdeaSynthesis/dokku-deploy-webhook)<sup>5</sup> | [fomojola][] | 0.8.1+ |
|
||||
|
||||
[217d00a]: https://github.com/dokku/dokku/commit/217d00a1bc47a7e24d8847617bb08a1633025fc7
|
||||
|
||||
@@ -211,7 +212,9 @@ The following plugins are available and provided by Dokku maintainers. Please f
|
||||
|
||||
<sup>3</sup> Adds the ability to add custom hosts to the containers known_hosts file to be able to ssh them easily (useful with deployment keys)
|
||||
|
||||
<sup>4</sup> Adds the ability to sync an application repo with a remote Github repo (useful for automated rebuilds without needing a git push from an external system).
|
||||
<sup>4</sup> Adds the ability to sync an application repo with a remote Github repo (useful for automated rebuilds without needing a git push from an external system
|
||||
|
||||
<sup>5</sup> Adds the ability to invoke a post-deploy webhook with the IP, port and app name, all with a single config:set).
|
||||
|
||||
### Other Plugins
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ The following config variables have special meanings and can be set in a variety
|
||||
| Name | Default | How to modify | Description |
|
||||
| ------------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
||||
| `DOKKU_ROOT` | `~dokku` | `/etc/environment` | The root directory where dokku will store application repositories, as well as certain configuration files. |
|
||||
| `DOKKU_IMAGE` | `gliderlabs/herokuish` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | The default image to use when building herokuish containers. |
|
||||
| `DOKKU_IMAGE` | `gliderlabs/herokuish` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | The default image to use when building herokuish containers. Deprecated in favor of using `buildpacks:set-property` |
|
||||
| `DOKKU_LIB_ROOT` | `/var/lib/dokku` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | The directory where plugins, certain data, and general configuration is stored. |
|
||||
| `PLUGIN_PATH` | `$DOKKU_LIB_ROOT/plugins"` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | The top-level directory where plugins are stored. |
|
||||
| `PLUGIN_AVAILABLE_PATH` | `$PLUGIN_PATH/available"` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | The directory that holds all available plugins, including core. |
|
||||
|
||||
@@ -61,6 +61,20 @@ The following options are also available via the `nginx:set` command:
|
||||
|
||||
Beware that if you enable the header and a subsequent deploy of your application results in an HTTP deploy (for whatever reason), the way the header works means that a browser will not attempt to request the HTTP version of your site if the HTTPS version fails until the max-age is reached.
|
||||
|
||||
#### Globally disabling the HSTS Header
|
||||
|
||||
HSTS Header can be disabled for all apps by setting the `hsts` property to false after passing the `--global` flag to `nginx:set`. Changing this value globally or on a per-app basis will require rebuilding the nginx config via the `nginx:build-config` command.
|
||||
|
||||
```shell
|
||||
dokku nginx:set --global hsts false
|
||||
```
|
||||
|
||||
Once the HSTS setting is disabled globally, it can be re-enabled on a per-app basis by setting the `hsts` property as normal.
|
||||
|
||||
```shell
|
||||
dokku nginx:set node-js-app hsts true
|
||||
```
|
||||
|
||||
### Checking access logs
|
||||
|
||||
You may check nginx access logs via the `nginx:access-logs` command. This assumes that app access logs are being stored in `/var/log/nginx/$APP-access.log`, as is the default in the generated `nginx.conf`.
|
||||
@@ -144,6 +158,28 @@ dokku nginx:set node-js-app proxy-read-timeout
|
||||
|
||||
In all cases, the nginx config must be regenerated after setting the above value.
|
||||
|
||||
### Specifying a custom client_max_body_size
|
||||
|
||||
> New as of 0.23.0
|
||||
|
||||
Users can override the default `client_max_body_size` value - which limits file uploads - via `nginx:set`. Changing this value will only apply to every `server` stanza of the default `nginx.conf.sigil`; users of custom `nginx.conf.sigil` files must update their templates to support the new value.
|
||||
|
||||
```shell
|
||||
dokku nginx:set node-js-app client-max-body-size 50m
|
||||
```
|
||||
|
||||
The default value is empty string, which will result in nginx falling back to any configured, higher-level defaults (or `1m` if unconfigued; all numerical values _must_ have a size unit specified (`k` for kilobytes, `m` for megabytes).
|
||||
|
||||
The default value may be set by passing an empty value for the option:
|
||||
|
||||
```shell
|
||||
dokku nginx:set node-js-app client-max-body-size
|
||||
```
|
||||
|
||||
In all cases, the nginx config must be regenerated after setting the above value.
|
||||
|
||||
Changing this value when using the PHP buildpack (or any other buildpack that uses an intermediary server) will require changing the value in the server config shipped with that buildpack. Consult your buildpack documentation for further details.
|
||||
|
||||
### Showing the nginx config
|
||||
|
||||
For debugging purposes, it may be useful to show the nginx config. This can be achieved via the `nginx:show-config` command.
|
||||
@@ -233,11 +269,11 @@ The default nginx.conf template will include everything from your apps `nginx.co
|
||||
include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf;
|
||||
```
|
||||
|
||||
That means you can put additional configuration in separate files, for example to limit the uploaded body size to 50 megabytes, do
|
||||
That means you can put additional configuration in separate files. To increase the client request header timeout, the following can be performed:
|
||||
|
||||
```shell
|
||||
mkdir /home/dokku/node-js-app/nginx.conf.d/
|
||||
echo 'client_max_body_size 50m;' > /home/dokku/node-js-app/nginx.conf.d/upload.conf
|
||||
echo 'client_header_timeout 50s;' > /home/dokku/node-js-app/nginx.conf.d/timeout.conf
|
||||
chown dokku:dokku /home/dokku/node-js-app/nginx.conf.d/upload.conf
|
||||
service nginx reload
|
||||
```
|
||||
@@ -250,7 +286,7 @@ For PHP Buildpack users, you will also need to provide a `Procfile` and an accom
|
||||
|
||||
Your `nginx.conf` file - not to be confused with Dokku's `nginx.conf.sigil` - would also need to be configured as shown in this example:
|
||||
|
||||
client_max_body_size 50m;
|
||||
client_header_timeout 50s;
|
||||
location / {
|
||||
index index.php;
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
|
||||
@@ -136,35 +136,12 @@ Certain versions of nginx have bugs that prevent [HTTP/2](https://nginx.org/en/d
|
||||
|
||||
Your application has access to the HTTP headers `X-Forwarded-Proto`, `X-Forwarded-Port` and `X-Forwarded-For`. These headers indicate the protocol of the original request (HTTP or HTTPS), the port number, and the IP address of the client making the request, respectively. The default configuration is for Nginx to set these headers.
|
||||
|
||||
If your server runs behind an HTTP(S) load balancer, then Nginx will see all requests as coming from the load balancer. If your load balancer sets the `X-Forwarded-` headers, you can tell Nginx to pass these headers from load balancer to your application by using a [custom nginx template](/docs/configuration/nginx.md#customizing-the-nginx-configuration). The following is a simple example of how to do so.
|
||||
If your server runs behind an HTTP(S) load balancer, then Nginx will see all requests as coming from the load balancer. If your load balancer sets the `X-Forwarded-` headers, you can tell Nginx to pass these headers from load balancer to your application via `nginx:set`:
|
||||
|
||||
```go
|
||||
server {
|
||||
listen [::]:{{ .PROXY_PORT }};
|
||||
listen {{ .PROXY_PORT }};
|
||||
server_name {{ .NOSSL_SERVER_NAME }};
|
||||
access_log /var/log/nginx/{{ .APP }}-access.log;
|
||||
error_log /var/log/nginx/{{ .APP }}-error.log;
|
||||
|
||||
location / {
|
||||
proxy_pass http://{{ .APP }};
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
|
||||
proxy_set_header X-Request-Start $msec;
|
||||
}
|
||||
include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf;
|
||||
}
|
||||
|
||||
upstream {{ .APP }} {
|
||||
{{ range .DOKKU_APP_WEB_LISTENERS | split " " }}
|
||||
server {{ . }};
|
||||
{{ end }}
|
||||
}
|
||||
```shell
|
||||
dokku nginx:set node-js-app x-forwarded-for-value "\$http_x_forwarded_for"
|
||||
dokku nginx:set node-js-app x-forwarded-port-value "\$http_x_forwarded_port"
|
||||
dokku nginx:set node-js-app x-forwarded-proto-value "\$http_x_forwarded_proto"
|
||||
```
|
||||
|
||||
Only use this option if:
|
||||
@@ -173,8 +150,6 @@ Only use this option if:
|
||||
|
||||
If it's possible to make HTTP(S) requests directly to Nginx, bypassing the load balancer, or if the load balancer is not configured to set these headers, then it becomes possible for a client to set these headers to arbitrary values.
|
||||
|
||||
This could result in security issue, for example, if your application looks at the value of the `X-Forwarded-Proto` to determine if the request was made over HTTPS.
|
||||
|
||||
### SSL Port Exposure
|
||||
|
||||
When your app is served from port `80` then the `/home/dokku/APP/nginx.conf` file will automatically be updated to instruct nginx to respond to ssl on port 443 as a new cert is added. If your app uses a non-standard port (perhaps you have a dockerfile deploy exposing port `99999`) you may need to manually expose an ssl port via `dokku proxy:ports-add <APP> https:443:99999`.
|
||||
|
||||
@@ -57,6 +57,34 @@ You may also fetch all failed app logs by using the `--all` flag.
|
||||
dokku logs:failed --all
|
||||
```
|
||||
|
||||
### Docker Log Retention
|
||||
|
||||
Docker log retention can be specified via the `logs:set` command by specifying a value for `max-size`. Log retention is set via injected docker options for all applications, but is also available via the `logs-get-property` trigger for alternative schedulers.
|
||||
|
||||
```shell
|
||||
dokku logs:set node-js-app max-size 20m
|
||||
```
|
||||
|
||||
The default value may be set by passing an empty value for the option:
|
||||
|
||||
```shell
|
||||
dokku logs:set node-js-app max-size
|
||||
```
|
||||
|
||||
Valid values include any integer number followed by a unit of measure (`k`, `m`, or `g`) or the string `unlimited`. Setting to `unlimited` will result in Dokku omitting the log option.
|
||||
|
||||
The `max-size` property can also be set globally. The global default is `10m`, and the global value is used when no app-specific value is set.
|
||||
|
||||
```shell
|
||||
dokku logs:set --global max-size 20m
|
||||
```
|
||||
|
||||
The default value may be set by passing an empty value for the option.
|
||||
|
||||
```shell
|
||||
dokku logs:set --global max-size
|
||||
```
|
||||
|
||||
### Vector Logging Shipping
|
||||
|
||||
> New as of 0.22.6
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
> New as of 0.22.0
|
||||
|
||||
```
|
||||
buildpacks:set-property [--global|<app>] <key> <value> # Set or clear a buildpacks property for an app
|
||||
```
|
||||
Cloud Native Buildpacks are an evolution over the Buildpacks technology provided by the Herokuish builder. See the [herokuish buildpacks documentation](/docs/deployment/methods/herokuish.md) for more information on how to clear buildpack build cache for an application.
|
||||
|
||||
> Warning: This functionality uses the `pack` cli from the [Cloud Native Buildpacks](https://buildpacks.io) project to build apps. As the integration is experimental in Dokku, it is likely to change over time.
|
||||
@@ -22,10 +25,8 @@ Builds will proceed with the `pack` cli for the app from then on.
|
||||
|
||||
As this functionality is highly experimental, there are a number of caveats. Please note that not all issuesare listed below.
|
||||
|
||||
- The `heroku/buildpacks:latest` CNB builder is currently enforced. Specifying specific builders is not currently possible.
|
||||
- A future release will allow modifying the chosen builder.
|
||||
- Specifying specific buildpacks is not currently possible.
|
||||
- A future release will add support for the `buildpacks` plugin.
|
||||
- A future release will add support for specifying buildpacks via the `buildpacks` plugin.
|
||||
- There is currently no way to specify extra arguments for `pack` cli invocations.
|
||||
- A future release will add support for injecting extra arguments during the build process.
|
||||
- The default process type is `web`.
|
||||
@@ -33,3 +34,31 @@ As this functionality is highly experimental, there are a number of caveats. Ple
|
||||
- A future version will add integration with the `repo` plugin.
|
||||
- `pack` is not currently included with Dokku, nor is it added as a package dependency.
|
||||
- A future version will include it as a package dependency.
|
||||
|
||||
### Customizing the Buildpack stack builder
|
||||
|
||||
> New as of 0.23.0
|
||||
|
||||
The default stack builder in use by CNB buildpacks in Dokku is based on `heroku/buildpacks`. Users may desire to switch the stack builder to a custom version, either to update the operating system or to customize packages included with the stack builder. This can be performed via the `buildpacks:set-property` command.
|
||||
|
||||
```shell
|
||||
dokku buildpacks:set-property node-js-app stack paketobuildpacks/build:base-cnb
|
||||
```
|
||||
|
||||
The specified stack builder can also be unset by omitting the name of the stack builder when calling `buildpacks:set-property`.
|
||||
|
||||
```shell
|
||||
dokku buildpacks:set-property node-js-app stack
|
||||
```
|
||||
|
||||
A change in the stack builder value will execute the `post-stack-set` trigger.
|
||||
|
||||
Finally, stack builders can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_CNB_STACK` environment variable (`heroku/buildpacks` by default).
|
||||
|
||||
```shell
|
||||
# set globally
|
||||
dokku buildpacks:set-property --global stack paketobuildpacks/build:base-cnb
|
||||
|
||||
# unset globally
|
||||
dokku buildpacks:set-property --global stack
|
||||
```
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
> Subcommands new as of 0.12.0
|
||||
|
||||
```
|
||||
git:initialize <app> # Initialize a git repository for an app
|
||||
git:report [<app>] [<flag>] # Displays a git report for one or more apps
|
||||
git:set <app> <key> (<value>) # Set or clear a git property for an app
|
||||
git:allow-host <host> # Adds a host to known_hosts
|
||||
git:sync [--build] <app> <repository> [<git-ref>] # Clone or fetch an app from remote git repo
|
||||
git:initialize <app> # Initialize a git repository for an app
|
||||
git:public-key # Outputs the dokku public deploy key
|
||||
git:report [<app>] [<flag>] # Displays a git report for one or more apps
|
||||
git:set <app> <key> (<value>) # Set or clear a git property for an app
|
||||
```
|
||||
|
||||
Git-based deployment has been the traditional method of deploying applications in Dokku. As of v0.12.0, Dokku introduces a few ways to customize the experience of deploying via `git push`. A Git-based deployment currently supports building applications via:
|
||||
@@ -105,3 +108,50 @@ dokku git:set node-js-app keep-git-dir false
|
||||
# delete the .git directory during builds (default)
|
||||
dokku git:set node-js-app keep-git-dir ""
|
||||
```
|
||||
|
||||
### Initializing an app repository from a remote repository
|
||||
|
||||
> The application must exist before the repository can be initialized
|
||||
|
||||
A Dokku app repository can be initialized or updated from a remote git repository via the `git:sync` command. This command will either clone or fetch updates from a remote repository and has undefined behavior if the history cannot be fast-fowarded to the referenced repository reference. Any repository that can be cloned by the `dokku` user can be specified.
|
||||
|
||||
```shell
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git
|
||||
```
|
||||
|
||||
The `git:sync` command optionally takes an optional third parameter containing a git reference, which may be a branch, tag, or specific commit.
|
||||
|
||||
```shell
|
||||
# specify a branch
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git main
|
||||
|
||||
# specify a tag
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git 1
|
||||
|
||||
# specify a commit
|
||||
dokku git:sync node-js-app https://github.com/heroku/node-js-getting-started.git 97e6c72491c7531507bfc5413903e0e00e31e1b0
|
||||
```
|
||||
|
||||
By default, this command does not trigger an application build. To do so during a `git:sync`, specify the `--build` flag.
|
||||
|
||||
```shell
|
||||
dokku git:sync --build node-js-app https://github.com/heroku/node-js-getting-started.git
|
||||
```
|
||||
|
||||
### Allowing remote repository hosts
|
||||
|
||||
By default, the Dokku host may not have access to a server containing the remote repository. This can be initialized via the `git:allow-host` command.
|
||||
|
||||
```shell
|
||||
dokku git:allow-host github.com
|
||||
```
|
||||
|
||||
Note that this command is currently not idempotent and may add duplicate entries to the `~dokku/.ssh/known_hosts` file.
|
||||
|
||||
### Verifying the cloning public key
|
||||
|
||||
In order to clone a remote repository, the remote server should have the Dokku host's public key configured. This plugin does not currently create this key, but if there is one available, it can be shown via the `git:public-key` command.
|
||||
|
||||
```shell
|
||||
dokku git:public-key
|
||||
```
|
||||
|
||||
@@ -3,12 +3,13 @@
|
||||
> Subcommands new as of 0.15.0
|
||||
|
||||
```
|
||||
buildpacks:add [--index 1] <app> <buildpack> # Add new app buildpack while inserting into list of buildpacks if necessary
|
||||
buildpacks:clear <app> # Clear all buildpacks set on the app
|
||||
buildpacks:list <app> # List all buildpacks for an app
|
||||
buildpacks:remove <app> <buildpack> # Remove a buildpack set on the app
|
||||
buildpacks:report [<app>] [<flag>] # Displays a buildpack report for one or more apps
|
||||
buildpacks:set [--index 1] <app> <buildpack> # Set new app buildpack at a given position defaulting to the first buildpack if no index is specified
|
||||
buildpacks:add [--index 1] <app> <buildpack> # Add new app buildpack while inserting into list of buildpacks if necessary
|
||||
buildpacks:clear <app> # Clear all buildpacks set on the app
|
||||
buildpacks:list <app> # List all buildpacks for an app
|
||||
buildpacks:remove <app> <buildpack> # Remove a buildpack set on the app
|
||||
buildpacks:report [<app>] [<flag>] # Displays a buildpack report for one or more apps
|
||||
buildpacks:set [--index 1] <app> <buildpack> # Set new app buildpack at a given position defaulting to the first buildpack if no index is specified
|
||||
buildpacks:set-property [--global|<app>] <key> <value> # Set or clear a buildpacks property for an app
|
||||
```
|
||||
|
||||
> Warning: If using the `buildpacks` plugin, be sure to unset any `BUILDPACK_URL` and remove any such entries from a committed `.env` file. A specified `BUILDPACK_URL` will always override a `.buildpacks` file or the buildpacks plugin.
|
||||
@@ -123,6 +124,34 @@ The `buildpacks:clear` command can be used to clear all configured buildpacks fo
|
||||
dokku buildpacks:clear node-js-app
|
||||
```
|
||||
|
||||
### Customizing the Buildpack stack builder
|
||||
|
||||
> New as of 0.23.0
|
||||
|
||||
The default stack builder in use by Herokuish buildpacks in Dokku is based on `gliderlabs/herokuish:latest`. Typically, this is installed via an OS package which pulls the requisite Docker image. Users may desire to switch the stack builder to a custom version, either to update the operating system or to customize packages included with the stack builder. This can be performed via the `buildpacks:set-property` command.
|
||||
|
||||
```shell
|
||||
dokku buildpacks:set-property node-js-app stack gliderlabs/herokuish:latest
|
||||
```
|
||||
|
||||
The specified stack builder can also be unset by omitting the name of the stack builder when calling `buildpacks:set-property`.
|
||||
|
||||
```shell
|
||||
dokku buildpacks:set-property node-js-app stack
|
||||
```
|
||||
|
||||
A change in the stack builder value will execute the `post-stack-set` trigger.
|
||||
|
||||
Finally, stack builders can be set or unset globally as a fallback. This will take precedence over a globally set `DOKKU_IMAGE` environment variable (`gliderlabs/herokuish:latest` by default).
|
||||
|
||||
```shell
|
||||
# set globally
|
||||
dokku buildpacks:set-property --global stack gliderlabs/herokuish:latest
|
||||
|
||||
# unset globally
|
||||
dokku buildpacks:set-property --global stack
|
||||
```
|
||||
|
||||
### Displaying buildpack reports for an app
|
||||
|
||||
You can get a report about the app's buildpacks status using the `buildpacks:report` command:
|
||||
@@ -133,11 +162,20 @@ dokku buildpacks:report
|
||||
|
||||
```
|
||||
=====> node-js-app buildpacks information
|
||||
Buildpacks list: https://github.com/heroku/heroku-buildpack-nodejs.git
|
||||
Buildpacks computed stack: gliderlabs/herokuish:v0.5.23-20
|
||||
Buildpacks global stack: gliderlabs/herokuish:latest
|
||||
Buildpacks list: https://github.com/heroku/heroku-buildpack-nodejs.git
|
||||
Buildpacks stack: gliderlabs/herokuish:v0.5.23-20
|
||||
=====> python-sample buildpacks information
|
||||
Buildpacks list: https://github.com/heroku/heroku-buildpack-nodejs.git,https://github.com/heroku/heroku-buildpack-python.git
|
||||
Buildpacks computed stack: gliderlabs/herokuish:v0.5.23-20
|
||||
Buildpacks global stack: gliderlabs/herokuish:latest
|
||||
Buildpacks list: https://github.com/heroku/heroku-buildpack-nodejs.git,https://github.com/heroku/heroku-buildpack-python.git
|
||||
Buildpacks stack:
|
||||
=====> ruby-sample buildpacks information
|
||||
Buildpacks computed stack: gliderlabs/herokuish:v0.5.23-20
|
||||
Buildpacks global stack: gliderlabs/herokuish:latest
|
||||
Buildpacks list:
|
||||
Buildpacks stack:
|
||||
```
|
||||
|
||||
You can run the command for a specific app also.
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
# One-off Processes and Cron
|
||||
|
||||
Sometimes you need to either inspect running containers or run a one-off command under an application. In those cases, Dokku makes it easy to either connect to a running container or run a fresh container.
|
||||
|
||||
## Run a command in an app environment
|
||||
|
||||
```
|
||||
run [ --env KEY=VALUE | -e KEY=VALUE ] <app> <cmd> # Run a command in a new container using the current application image
|
||||
```
|
||||
|
||||
The `run` command can be used to run a one-off process for a specific command. This will start a new container and run the desired command within that container. Note that this container will be stay around even after command completes. The container will be the same container as was used to start the currently deployed application.
|
||||
|
||||
```shell
|
||||
# runs `ls -lah` in the `/app` directory of the application `node-js-app`
|
||||
dokku run node-js-app ls -lah
|
||||
|
||||
# optionally, run can be passed custom environment variables
|
||||
dokku run --env "NODE_ENV=development" --env "PATH=/custom/path" node-js-app npm run mytask
|
||||
```
|
||||
|
||||
The `run` command can also be used to run a command defined in your Procfile:
|
||||
|
||||
```
|
||||
console: bundle exec racksh
|
||||
```
|
||||
|
||||
```shell
|
||||
# runs `bundle exec racksh` in the `/app` directory of the application `my-app`
|
||||
dokku run my-app console
|
||||
```
|
||||
|
||||
If you want to remove the container after a command has started, you can run the following command:
|
||||
|
||||
```shell
|
||||
# don't keep `run` containers around
|
||||
dokku config:set --global DOKKU_RM_CONTAINER=1
|
||||
|
||||
# revert the above setting and keep containers around
|
||||
dokku config:unset --global DOKKU_RM_CONTAINER
|
||||
```
|
||||
|
||||
You may also use the `--rm-container` or `--rm` Dokku flags to remove the containers automatically:
|
||||
|
||||
```shell
|
||||
dokku --rm-container run node-js-app ls -lah
|
||||
dokku --rm run node-js-app ls -lah
|
||||
```
|
||||
|
||||
Containers may have specific labels attached. In order to avoid issues with dokku internals, do not use any labels beginning with either `com.dokku` or `org.label-schema`.
|
||||
|
||||
```shell
|
||||
dokku --label=com.example.test-label=value run node-js-app ls -lah
|
||||
```
|
||||
|
||||
Finally, you may wish to run a container in "detached" mode via the `--detach` Dokku flag. Running a process in detached mode will immediately return a `CONTAINER_ID`. It is up to the user to then further manage this container in whatever manner they see fit, as Dokku will *not* automatically terminate the container.
|
||||
|
||||
```shell
|
||||
dokku --detach run node-js-app ls -lah
|
||||
# returns the ID of the new container
|
||||
```
|
||||
|
||||
> Note that you may not use the `--rm-container` or `--rm` flags when running containers in detached mode, and attempting to do so will result in the `--detach` flag being ignored.
|
||||
|
||||
### Using `run` for cron tasks
|
||||
|
||||
You can always use a one-off container to run an application task:
|
||||
|
||||
```shell
|
||||
dokku --rm run node-js-app some-command
|
||||
dokku --rm-container run node-js-app some-command
|
||||
```
|
||||
|
||||
For tasks that should not be interrupted, run is the *preferred* method of handling cron tasks, as the container will continue running even during a deploy or scaling event. The trade-off is that there will be an increase in memory usage if there are multiple concurrent tasks running.
|
||||
|
||||
## Entering existing containers
|
||||
|
||||
> New as of 0.4.0
|
||||
|
||||
```
|
||||
enter <app> [<container-type> || --container-id <container-id>] # Connect to a specific app container
|
||||
```
|
||||
|
||||
The `enter` command can be used to enter a running container. The following variations of the command exist:
|
||||
|
||||
```shell
|
||||
dokku enter node-js-app web
|
||||
dokku enter node-js-app web.1
|
||||
dokku enter node-js-app --container-id ID
|
||||
```
|
||||
|
||||
Additionally, you can run `enter` with no `<container-type>`. If only a single `<container-type>` is defined in your app, you will be dropped into the only running container. This behavior is not supported when specifying a custom command; as described below.
|
||||
|
||||
By default, it runs a `/bin/bash`, but can also be used to run a custom command:
|
||||
|
||||
```shell
|
||||
# just echo hi
|
||||
dokku enter node-js-app web echo hi
|
||||
|
||||
# run a long-running command, as one might for a cron task
|
||||
dokku enter node-js-app web python script/background-worker.py
|
||||
```
|
||||
|
||||
### Using `enter` for cron tasks
|
||||
|
||||
Your Procfile can have the following entry:
|
||||
|
||||
```Procfile
|
||||
cron: sleep infinity
|
||||
```
|
||||
|
||||
With the `cron` process scaled to `1`:
|
||||
|
||||
```shell
|
||||
dokku ps:scale node-js-app cron=1
|
||||
```
|
||||
|
||||
You can now run all your commands in that container:
|
||||
|
||||
```shell
|
||||
dokku enter node-js-app cron some-command
|
||||
```
|
||||
|
||||
Note that you can also run multiple commands at the same time to reduce memory usage, though that may result in polluting the container environment.
|
||||
|
||||
For tasks that will properly resume, you *should* use the above method, as running tasks will be interrupted during deploys and scaling events, and subsequent commands will always run with the latest container. Note that if you scale the cron container down, this may interrupt proper running of the task.
|
||||
|
||||
## General cron recommendations
|
||||
|
||||
Regularly scheduled tasks can be a bit of a pain with Dokku. The following are general recommendations to follow to help ensure successful task runs.
|
||||
|
||||
- Use the `dokku` user's crontab.
|
||||
- If you do not, the `dokku` binary will attempt to execute with `sudo`, and your cron run with fail with `sudo: no tty present and no askpass program specified`.
|
||||
- Add a `MAILTO` environment variable to ship cron emails to yourself.
|
||||
- Add a `PATH` environment variable or specify the full path to binaries on the host.
|
||||
- Add a `SHELL` environment variable to specify Bash when running commands.
|
||||
- Keep your cron tasks in time-sorted order.
|
||||
- Keep your server time in UTC so you don't need to translate daylight savings time when reading the cronfile.
|
||||
- Run tasks at the lowest traffic times if possible.
|
||||
- Use cron to *trigger* jobs, not run them. Use a real queuing system such as rabbitmq to actually process jobs.
|
||||
- Try to keep tasks quiet so that mails only send on errors.
|
||||
- Do not silence standard error or standard out. If you silence the former, you will miss failures. Silencing the latter means you should actually make application changes to handle log levels.
|
||||
- Use a service such as [Dead Man's Snitch](https://deadmanssnitch.com) to verify that cron tasks completed successfully.
|
||||
- Add lots of comments to your cronfile, including what a task is doing, so that you don't spend time deciphering the file later.
|
||||
- Place your cronfiles in a pattern such as `/etc/cron.d/APP`.
|
||||
- Do not use non-ASCII characters in your cronfile names. cron is finicky.
|
||||
- Remember to have trailing newlines in your cronfile! cron is finicky.
|
||||
|
||||
The following is a sample cronfile that you can use for your applications:
|
||||
|
||||
```cron
|
||||
# server cron jobs
|
||||
MAILTO="mail@dokku.me"
|
||||
PATH=/usr/local/bin:/usr/bin:/bin
|
||||
SHELL=/bin/bash
|
||||
|
||||
# m h dom mon dow username command
|
||||
# * * * * * dokku command to be executed
|
||||
# - - - - -
|
||||
# | | | | |
|
||||
# | | | | +----- day of week (0 - 6) (Sunday=0)
|
||||
# | | | +------- month (1 - 12)
|
||||
# | | +--------- day of month (1 - 31)
|
||||
# | +----------- hour (0 - 23)
|
||||
# +----------- min (0 - 59)
|
||||
|
||||
### HIGH TRAFFIC TIME IS B/W 00:00 - 04:00 AND 14:00 - 23:59
|
||||
### RUN YOUR TASKS FROM 04:00 - 14:00
|
||||
### KEEP SORTED IN TIME ORDER
|
||||
|
||||
### PLACE ALL CRON TASKS BELOW
|
||||
|
||||
# removes unresponsive users from the subscriber list to decrease bounce rates
|
||||
0 0 * * * dokku dokku --rm run node-js-app some-command
|
||||
|
||||
# sends out our email alerts to users
|
||||
0 1 * * * dokku dokku ps:scale node-js-app cron=1 && dokku enter node-js-app cron some-other-command && dokku ps:scale node-js-app cron=0
|
||||
|
||||
### PLACE ALL CRON TASKS ABOVE, DO NOT REMOVE THE WHITESPACE AFTER THIS LINE
|
||||
|
||||
```
|
||||
@@ -309,6 +309,40 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
curl "http://httpstat.us/200"
|
||||
```
|
||||
|
||||
### `cron-write`
|
||||
|
||||
- Description: Force triggers writing out cron entries
|
||||
- Invoked by:
|
||||
- Arguments:
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `cron-entries`
|
||||
|
||||
- Description: Allows injecting cron entries into the written out scheduled cron task list. Each entry is newline delimited, and individual entries come in the form `$SCHEDULE;$FULL_COMMAND;$ARBITRARY_DATA`. Individual implementations of cron writing can decide whether and how to include these cron entries. The `ARBITRARY_DATA` includes the log file path for the basic `docker-local` cron implementation.
|
||||
- Invoked by:
|
||||
- Arguments: `$DOKKU_SCHEDULER`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||
|
||||
DOKKU_SCHEDULER="$1"
|
||||
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `dependencies`
|
||||
|
||||
- Description: Used to install system-level dependencies.
|
||||
@@ -699,6 +733,22 @@ if [[ ! -f "$DOKKU_ROOT/HOSTNAME" ]]; then
|
||||
fi
|
||||
```
|
||||
|
||||
### `logs-get-property`
|
||||
|
||||
- Description: Fetches a given logs property value
|
||||
- Invoked by:
|
||||
- Arguments: `$APP` `$PROPERTY`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
APP="$1"; PROPERTY="$2"
|
||||
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `network-build-config`
|
||||
|
||||
- Description: Rebuilds network configuration
|
||||
@@ -2092,6 +2142,21 @@ DOKKU_SCHEDULER="$1"; APP="$2"; IMAGE_REPO="$3"; IMAGE_TAG="$4";
|
||||
# TODO
|
||||
```
|
||||
|
||||
### `storage-list`
|
||||
|
||||
- Description: Returns a list of storage mounts
|
||||
- Invoked by: `dokku storage:list` and `dokku deploy`
|
||||
- Arguments: `$APP`
|
||||
- Example:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
APP="$1"
|
||||
|
||||
# TODO
|
||||
```
|
||||
### `tags-create`
|
||||
|
||||
- Description: Allows you to run commands once a tag for an app image has been added
|
||||
|
||||
@@ -29,7 +29,7 @@ The workflow looks like this:
|
||||
```shell
|
||||
# having dokku-arch in ../dokku-arch
|
||||
vagrant up build-arch
|
||||
# wait for "==> build-arch: ==> Finished making: dokku 0.22.9-2 (Mon Feb 22 23:20:37 CET 2016)"
|
||||
# wait for "==> build-arch: ==> Finished making: dokku 0.23.2-2 (Mon Feb 22 23:20:37 CET 2016)"
|
||||
cd ../dokku-arch
|
||||
git add PKGBUILD .SRCINFO
|
||||
git commit -m 'Update to dokku 0.9.9'
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# DigitalOcean Droplet Installation Notes
|
||||
|
||||
[DigitalOcean](https://www.digitalocean.com/products/compute/) offers a pre-installed Dokku image. You can run this image on any sized Droplet, although larger Droplets will allow you to run larger applications.
|
||||
[DigitalOcean](https://marketplace.digitalocean.com/apps/dokku?refcode=fe06b043a083) offers a pre-installed Dokku image. You can run this image on any sized Droplet, although larger Droplets will allow you to run larger applications.
|
||||
|
||||
> **Please disable IPv6**. There are known issues with IPv6 on DigitalOcean and Docker. If you would like to run Dokku on an IPv6 DigitalOcean Droplet, please consult [this guide](https://jeffloughridge.wordpress.com/2015/01/17/native-ipv6-functionality-in-docker/).
|
||||
|
||||
1. Login to your [DigitalOcean](https://m.do.co/c/fe06b043a083) account.
|
||||
2. Click **Create a Droplet**.
|
||||
3. Under **Choose an image > One-click apps**, choose the latest **Dokku** release for 18.04 _(version numbers may vary)_.
|
||||
3. Under **Choose an image > Marketplace**, search latest **Dokku** release for Ubuntu 20.04 _(version numbers may vary)_.
|
||||
4. Under **Choose a size**, select your machine spec.
|
||||
5. Under **Choose a datacenter region**, select your region.
|
||||
6. Add an SSH Key.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Pull the dokku/dokku image:
|
||||
|
||||
```shell
|
||||
docker pull dokku/dokku:0.22.9
|
||||
docker pull dokku/dokku:0.23.2
|
||||
```
|
||||
|
||||
Next, run the image.
|
||||
@@ -17,7 +17,7 @@ docker run \
|
||||
--publish 8443:443 \
|
||||
--volume /var/lib/dokku:/mnt/dokku \
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock \
|
||||
dokku/dokku:0.22.9
|
||||
dokku/dokku:0.23.2
|
||||
```
|
||||
|
||||
Dokku is run in the following configuration:
|
||||
|
||||
@@ -21,8 +21,8 @@ To install the latest stable version of Dokku, you can run the following shell c
|
||||
|
||||
```shell
|
||||
# for debian systems, installs Dokku via apt-get
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.22.9/bootstrap.sh;
|
||||
sudo DOKKU_TAG=v0.22.9 bash bootstrap.sh
|
||||
wget https://raw.githubusercontent.com/dokku/dokku/v0.23.2/bootstrap.sh;
|
||||
sudo DOKKU_TAG=v0.23.2 bash bootstrap.sh
|
||||
```
|
||||
|
||||
The installation process takes about 5-10 minutes, depending upon internet connection speed.
|
||||
|
||||
@@ -19,6 +19,7 @@ Docker releases updates periodically to their engine. We recommend reading their
|
||||
|
||||
Before upgrading, check the migration guides to get comfortable with new features and prepare your deployment to be upgraded.
|
||||
|
||||
- [Upgrading to 0.23](/docs/appendices/0.23.0-migration-guide.md)
|
||||
- [Upgrading to 0.22](/docs/appendices/0.22.0-migration-guide.md)
|
||||
- [Upgrading to 0.21](/docs/appendices/0.21.0-migration-guide.md)
|
||||
- [Upgrading to 0.20](/docs/appendices/0.20.0-migration-guide.md)
|
||||
@@ -93,10 +94,10 @@ If Dokku was installed in a Debian or Ubuntu system, via `apt-get install dokku`
|
||||
|
||||
```shell
|
||||
# update your local apt cache
|
||||
sudo apt-get update
|
||||
sudo apt-get update -qq
|
||||
|
||||
# update dokku and its dependencies
|
||||
sudo apt-get -qq -y install dokku herokuish sshcommand plugn gliderlabs-sigil
|
||||
sudo apt-get -qq -y --no-install-recommends install dokku herokuish sshcommand plugn gliderlabs-sigil dokku-update dokku-event-listener
|
||||
|
||||
# or just upgrade every package:
|
||||
sudo apt-get upgrade
|
||||
|
||||
@@ -10,30 +10,30 @@
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
|
||||
<title>Dokku - The smallest PaaS implementation you've ever seen</title>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-32x32.png" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/android-chrome-192x192.png" sizes="192x192">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-96x96.png" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/manifest.json">
|
||||
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-32x32.png" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/android-chrome-192x192.png" sizes="192x192">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-96x96.png" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/manifest.json">
|
||||
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon.ico">
|
||||
<meta name="apple-mobile-web-app-title" content="Dokku">
|
||||
<meta name="application-name" content="Dokku">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-TileImage" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-144x144.png">
|
||||
<meta name="msapplication-config" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/browserconfig.xml">
|
||||
<meta name="msapplication-TileImage" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-144x144.png">
|
||||
<meta name="msapplication-config" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/style.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/style.css" rel="stylesheet">
|
||||
<!-- <link href="/dokku/docs/assets/style.css" rel="stylesheet"> -->
|
||||
<style>
|
||||
.sponsors {
|
||||
@@ -130,12 +130,12 @@
|
||||
<p class="line">
|
||||
<span class="path"></span>
|
||||
<span class="prompt">$</span>
|
||||
<span class="command">wget https://raw.githubusercontent.com/dokku/dokku/v0.22.9/bootstrap.sh</span>
|
||||
<span class="command">wget https://raw.githubusercontent.com/dokku/dokku/v0.23.2/bootstrap.sh</span>
|
||||
</p>
|
||||
<p class="line">
|
||||
<span class="path"></span>
|
||||
<span class="prompt">$</span>
|
||||
<span class="command">sudo DOKKU_TAG=v0.22.9 bash bootstrap.sh</span>
|
||||
<span class="command">sudo DOKKU_TAG=v0.23.2 bash bootstrap.sh</span>
|
||||
</p>
|
||||
<p class="line">
|
||||
<span class="output"> # go to your server's IP and follow the web installer</span>
|
||||
@@ -215,7 +215,7 @@
|
||||
</div>
|
||||
|
||||
<div class="alternate-instructions">
|
||||
<p>Hate <code>curl | bash</code>? See our official <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/dokku-vm" target="_blank">Azure</a>, <a href="https://www.digitalocean.com/features/one-click-apps/dokku/" target="_blank">DigitalOcean</a>, and <a href="/{{NAME}}~{{REF}}/getting-started/install/dreamhost/">DreamHost Cloud</a> instructions.</p>
|
||||
<p>Hate <code>curl | bash</code>? See our official <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/dokku-vm" target="_blank">Azure</a>, <a href="https://marketplace.digitalocean.com/apps/dokku?refcode=fe06b043a083 target="_blank">DigitalOcean</a>, and <a href="/{{NAME}}~{{REF}}/getting-started/install/dreamhost/">DreamHost Cloud</a> instructions.</p>
|
||||
<p>Still no love? <a href="https://github.com/dokku/dokku/blob/master/CONTRIBUTING.md" target="_blank">Contributions welcome</a>!</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
29
docs/processes/entering-containers.md
Normal file
29
docs/processes/entering-containers.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Entering containers
|
||||
|
||||
> New as of 0.4.0
|
||||
|
||||
```
|
||||
enter <app> [<container-type> || --container-id <container-id>] # Connect to a specific app container
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The `enter` command can be used to enter a running container. The following variations of the command exist:
|
||||
|
||||
```shell
|
||||
dokku enter node-js-app web
|
||||
dokku enter node-js-app web.1
|
||||
dokku enter node-js-app --container-id ID
|
||||
```
|
||||
|
||||
Additionally, the `enter` command can be executed with no `<container-type>`. If only a single `<container-type>` is defined in the app's Procfile, executing `enter` will drop the terminal into the only running container. This behavior is not supported when specifying a custom command; as described below.
|
||||
|
||||
By default, it runs a `/bin/bash`, but can also be used to run a custom command:
|
||||
|
||||
```shell
|
||||
# just echo hi
|
||||
dokku enter node-js-app web echo hi
|
||||
|
||||
# run a long-running command, as one might for a cron task
|
||||
dokku enter node-js-app web python script/background-worker.py
|
||||
```
|
||||
62
docs/processes/one-off-tasks.md
Normal file
62
docs/processes/one-off-tasks.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# One-off Tasks
|
||||
|
||||
```
|
||||
run [ --env KEY=VALUE | -e KEY=VALUE ] <app> <cmd> # Run a command in a new container using the current application image
|
||||
```
|
||||
|
||||
Sometimes it is necessary to run a one-off command under an application. Dokku makes it easy to run a fresh container via the `run` command.
|
||||
|
||||
## Usage
|
||||
|
||||
The `run` command can be used to run a one-off process for a specific command. This will start a new container and run the desired command within that container. Note that this container will be stay around even after command completes. The container will be the same container as was used to start the currently deployed application.
|
||||
|
||||
```shell
|
||||
# runs `ls -lah` in the `/app` directory of the application `node-js-app`
|
||||
dokku run node-js-app ls -lah
|
||||
|
||||
# optionally, run can be passed custom environment variables
|
||||
dokku run --env "NODE_ENV=development" --env "PATH=/custom/path" node-js-app npm run mytask
|
||||
```
|
||||
|
||||
The `run` command can also be used to run a command defined in the app `Procfile`:
|
||||
|
||||
```
|
||||
console: bundle exec racksh
|
||||
```
|
||||
|
||||
```shell
|
||||
# runs `bundle exec racksh` in the `/app` directory of the application `my-app`
|
||||
dokku run my-app console
|
||||
```
|
||||
|
||||
If the container running the command should be removed after exit, the `--rm-container` or `--rm` global flags can be specified to remove the containers automatically:
|
||||
|
||||
```shell
|
||||
dokku --rm-container run node-js-app ls -lah
|
||||
dokku --rm run node-js-app ls -lah
|
||||
```
|
||||
|
||||
Alternatively, a global property can be set to always remove `run` containers.
|
||||
|
||||
```shell
|
||||
# don't keep `run` containers around
|
||||
dokku config:set --global DOKKU_RM_CONTAINER=1
|
||||
|
||||
# revert the above setting and keep containers around
|
||||
dokku config:unset --global DOKKU_RM_CONTAINER
|
||||
```
|
||||
|
||||
Containers may have specific labels attached. In order to avoid issues with dokku internals, do not use any labels beginning with either `com.dokku` or `org.label-schema`.
|
||||
|
||||
```shell
|
||||
dokku --label=com.example.test-label=value run node-js-app ls -lah
|
||||
```
|
||||
|
||||
Finally, a container can be run in "detached" mode via the `--detach` Dokku flag. Running a process in detached mode will immediately return a `CONTAINER_ID`. It is up to the user to then further manage this container in whatever manner they see fit, as Dokku will *not* automatically terminate the container.
|
||||
|
||||
```shell
|
||||
dokku --detach run node-js-app ls -lah
|
||||
# returns the ID of the new container
|
||||
```
|
||||
|
||||
> Note that the `--rm-container` or `--rm` flags cannot be used when running containers in detached mode, and attempting to do so will result in the `--detach` flag being ignored.
|
||||
193
docs/processes/scheduled-cron-tasks.md
Normal file
193
docs/processes/scheduled-cron-tasks.md
Normal file
@@ -0,0 +1,193 @@
|
||||
# Scheduled Cron Tasks
|
||||
|
||||
> New as of 0.23.0
|
||||
|
||||
```
|
||||
cron:list <app> # List scheduled cron tasks for an app
|
||||
cron:report [<app>] [<flag>] # Display report about an app
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Dokku Managed Cron
|
||||
|
||||
Dokku automates scheduled `dokku run` commands via it's `app.json` cron integration.
|
||||
|
||||
#### Specifying commands
|
||||
|
||||
The `app.json` file for a given app can define a special `cron` key that contains a list of commands to run on given schedules. The following is a simple example `app.json` that simply runs the command `true` once a day:
|
||||
|
||||
```
|
||||
{
|
||||
"cron": [
|
||||
{
|
||||
"command": "true",
|
||||
"schedule": "@daily"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
A cron entry takes the following properties:
|
||||
|
||||
- `command`: A command to be run within the built app image. Specified commands can also be `Procfile` entries.
|
||||
- `schedule`: A [cron-compatible](https://en.wikipedia.org/wiki/Cron#Overview) scheduling definition upon which to run the command. Seconds are generally not supported.
|
||||
|
||||
Zero or more cron commands can be specified per app. Cron entries are validated after the build artifact is created but before the app is deployed, and the cron schedule is updated during the post-deploy phase.
|
||||
|
||||
#### Task Environment
|
||||
|
||||
When running scheduled cron tasks, there are a few items to be aware of:
|
||||
|
||||
- Scheduled cron tasks are performed within the app environment available at runtime. If the app image does not exist, the command may fail to execute.
|
||||
- Schedules are performed on the hosting server's timezone, which is typically UTC.
|
||||
- At this time, only the `PATH` and `SHELL` environment variables are specified in the cron template.
|
||||
- Each scheduled task is executed within a one-off `run` container, and thus inherit any docker-options specified for `run` containers.Resources are never shared between scheduled tasks.
|
||||
- Tasks are always executed using the `--rm` flag, and are never executed in detached mode.
|
||||
- Scheduled cron tasks are supported on a per-scheduler basis, and are currently only implemented by the `docker-local` scheduler.
|
||||
- Tasks for _all_ apps managed by the `docker-local` scheduler are written to a single crontab file owned by the `dokku` user. The `dokku` user's crontab should be considered reserved for this purpose.
|
||||
|
||||
#### Listing Cron tasks
|
||||
|
||||
Cron tasks for an app can be listed via the `cron:list` command. This command takes an `app` argument.
|
||||
|
||||
```shell
|
||||
dokku cron:list node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
ID Schedule Command
|
||||
cGhwPT09cGhwIHRlc3QucGhwPT09QGRhaWx5 @daily node index.js
|
||||
cGhwPT09dHJ1ZT09PSogKiAqICogKg== * * * * * true
|
||||
```
|
||||
|
||||
#### Displaying reports for an app
|
||||
|
||||
You can get a report about the cron configuration for apps using the `cron:report` command:
|
||||
|
||||
```shell
|
||||
dokku cron:report node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app cron information
|
||||
Cron task count: 2
|
||||
=====> python-sample cron information
|
||||
Cron task count: 0
|
||||
=====> ruby-sample cron information
|
||||
Cron task count: 10
|
||||
```
|
||||
|
||||
You can run the command for a specific app also.
|
||||
|
||||
```shell
|
||||
dokku cron:report node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> node-js-app cron information
|
||||
Cron task count: 2
|
||||
```
|
||||
|
||||
You can pass flags which will output only the value of the specific information you want. For example:
|
||||
|
||||
```shell
|
||||
dokku cron:report node-js-app --cron-task-count
|
||||
```
|
||||
|
||||
### Self Managed Cron
|
||||
|
||||
> Warning: Self-managed cron tasks should be considered advanced usage. While the instructions are available, users are highly encouraged to use the built-in scheduled cron task support unless absolutely necessary.
|
||||
|
||||
Some installations may require more fine-grained control over cron usage. The following are advanced instructions for configuring cron.
|
||||
|
||||
#### Using `run` for cron tasks
|
||||
|
||||
You can always use a one-off container to run an app task:
|
||||
|
||||
```shell
|
||||
dokku --rm run node-js-app some-command
|
||||
dokku --rm-container run node-js-app some-command
|
||||
```
|
||||
|
||||
For tasks that should not be interrupted, run is the *preferred* method of handling cron tasks, as the container will continue running even during a deploy or scaling event. The trade-off is that there will be an increase in memory usage if there are multiple concurrent tasks running.
|
||||
|
||||
|
||||
#### Using `enter` for cron tasks
|
||||
|
||||
Your Procfile can have the following entry:
|
||||
|
||||
```Procfile
|
||||
cron: sleep infinity
|
||||
```
|
||||
|
||||
With the `cron` process scaled to `1`:
|
||||
|
||||
```shell
|
||||
dokku ps:scale node-js-app cron=1
|
||||
```
|
||||
|
||||
You can now run all your commands in that container:
|
||||
|
||||
```shell
|
||||
dokku enter node-js-app cron some-command
|
||||
```
|
||||
|
||||
Note that you can also run multiple commands at the same time to reduce memory usage, though that may result in polluting the container environment.
|
||||
|
||||
For tasks that will properly resume, you *should* use the above method, as running tasks will be interrupted during deploys and scaling events, and subsequent commands will always run with the latest container. Note that if you scale the cron container down, this may interrupt proper running of the task.
|
||||
|
||||
#### General cron recommendations
|
||||
|
||||
Regularly scheduled tasks can be a bit of a pain with Dokku. The following are general recommendations to follow to help ensure successful task runs.
|
||||
|
||||
- Use the `dokku` user in your cron entry.
|
||||
- If you do not, the `dokku` binary will attempt to execute with `sudo`, and your cron run with fail with `sudo: no tty present and no askpass program specified`.
|
||||
- Add a `MAILTO` environment variable to ship cron emails to yourself.
|
||||
- Add a `PATH` environment variable or specify the full path to binaries on the host.
|
||||
- Add a `SHELL` environment variable to specify Bash when running commands.
|
||||
- Keep your cron tasks in time-sorted order.
|
||||
- Keep your server time in UTC so you don't need to translate daylight savings time when reading the cronfile.
|
||||
- Run tasks at the lowest traffic times if possible.
|
||||
- Use cron to *trigger* jobs, not run them. Use a real queuing system such as rabbitmq to actually process jobs.
|
||||
- Try to keep tasks quiet so that mails only send on errors.
|
||||
- Do not silence standard error or standard out. If you silence the former, you will miss failures. Silencing the latter means you should actually make app changes to handle log levels.
|
||||
- Use a service such as [Dead Man's Snitch](https://deadmanssnitch.com) to verify that cron tasks completed successfully.
|
||||
- Add lots of comments to your cronfile, including what a task is doing, so that you don't spend time deciphering the file later.
|
||||
- Place your cronfiles in a pattern such as `/etc/cron.d/APP`.
|
||||
- Do not use non-ASCII characters in your cronfile names. cron is finicky.
|
||||
- Remember to have trailing newlines in your cronfile! cron is finicky.
|
||||
|
||||
The following is a sample cronfile that you can use for your apps:
|
||||
|
||||
```cron
|
||||
# server cron jobs
|
||||
MAILTO="mail@dokku.me"
|
||||
PATH=/usr/local/bin:/usr/bin:/bin
|
||||
SHELL=/bin/bash
|
||||
|
||||
# m h dom mon dow username command
|
||||
# * * * * * dokku command to be executed
|
||||
# - - - - -
|
||||
# | | | | |
|
||||
# | | | | +----- day of week (0 - 6) (Sunday=0)
|
||||
# | | | +------- month (1 - 12)
|
||||
# | | +--------- day of month (1 - 31)
|
||||
# | +----------- hour (0 - 23)
|
||||
# +----------- min (0 - 59)
|
||||
|
||||
### HIGH TRAFFIC TIME IS B/W 00:00 - 04:00 AND 14:00 - 23:59
|
||||
### RUN YOUR TASKS FROM 04:00 - 14:00
|
||||
### KEEP SORTED IN TIME ORDER
|
||||
|
||||
### PLACE ALL CRON TASKS BELOW
|
||||
|
||||
# removes unresponsive users from the subscriber list to decrease bounce rates
|
||||
0 0 * * * dokku dokku --rm run node-js-app some-command
|
||||
|
||||
# sends out our email alerts to users
|
||||
0 1 * * * dokku dokku ps:scale node-js-app cron=1 && dokku enter node-js-app cron some-other-command && dokku ps:scale node-js-app cron=0
|
||||
|
||||
### PLACE ALL CRON TASKS ABOVE, DO NOT REMOVE THE WHITESPACE AFTER THIS LINE
|
||||
|
||||
```
|
||||
@@ -9,26 +9,26 @@
|
||||
<meta name="author" content="">
|
||||
<title>Dokku - The smallest PaaS implementation you've ever seen</title>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/apple-touch-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-32x32.png" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/android-chrome-192x192.png" sizes="192x192">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-96x96.png" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/manifest.json">
|
||||
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="57x57" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-57x57.png">
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-60x60.png">
|
||||
<link rel="apple-touch-icon" sizes="72x72" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-72x72.png">
|
||||
<link rel="apple-touch-icon" sizes="76x76" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-76x76.png">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-114x114.png">
|
||||
<link rel="apple-touch-icon" sizes="120x120" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-120x120.png">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-144x144.png">
|
||||
<link rel="apple-touch-icon" sizes="152x152" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-152x152.png">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/apple-touch-icon-180x180.png">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-32x32.png" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/android-chrome-192x192.png" sizes="192x192">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-96x96.png" sizes="96x96">
|
||||
<link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/manifest.json">
|
||||
<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/favicon.ico">
|
||||
<meta name="apple-mobile-web-app-title" content="Dokku">
|
||||
<meta name="application-name" content="Dokku">
|
||||
<meta name="msapplication-TileColor" content="#da532c">
|
||||
<meta name="msapplication-TileImage" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/mstile-144x144.png">
|
||||
<meta name="msapplication-config" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/favicons/browserconfig.xml">
|
||||
<meta name="msapplication-TileImage" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/mstile-144x144.png">
|
||||
<meta name="msapplication-config" content="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/favicons/browserconfig.xml">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<script>
|
||||
@@ -42,7 +42,7 @@
|
||||
</script>
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.22.9/docs/assets/style.css" rel="stylesheet">
|
||||
<link href="https://cdn.jsdelivr.net/gh/dokku/dokku@v0.23.2/docs/assets/style.css" rel="stylesheet">
|
||||
<!-- <link href="/dokku/docs/assets/style.css" rel="stylesheet"> -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<style>
|
||||
@@ -124,8 +124,6 @@
|
||||
<a href="/{{NAME}}/deployment/application-management/" class="list-group-item">Application Management</a>
|
||||
<a href="/{{NAME}}/deployment/logs/" class="list-group-item">Application Logs</a>
|
||||
<a href="/{{NAME}}/deployment/remote-commands/" class="list-group-item">Remote Commands</a>
|
||||
<a href="/{{NAME}}/deployment/one-off-processes/" class="list-group-item">One-Off Processes/Cron</a>
|
||||
<a href="/{{NAME}}/deployment/process-management/" class="list-group-item">Process Scaling</a>
|
||||
<a href="/{{NAME}}/deployment/user-management/" class="list-group-item">User Management</a>
|
||||
<a href="/{{NAME}}/deployment/zero-downtime-deploys/" class="list-group-item">Zero Downtime Deploy Checks</a>
|
||||
|
||||
@@ -145,6 +143,13 @@
|
||||
<a href="/{{NAME}}/configuration/nginx/" class="list-group-item">Nginx Configuration</a>
|
||||
<a href="/{{NAME}}/configuration/ssl/" class="list-group-item">SSL Configuration</a>
|
||||
|
||||
<a href="#" class="list-group-item disabled">Process Management</a>
|
||||
|
||||
<a href="/{{NAME}}/processes/entering-containers/" class="list-group-item">Entering Containers</a>
|
||||
<a href="/{{NAME}}/processes/one-off-tasks/" class="list-group-item">One-Off Tasks</a>
|
||||
<a href="/{{NAME}}/processes/process-management/" class="list-group-item">Process Scaling</a>
|
||||
<a href="/{{NAME}}/processes/scheduled-cron-tasks/" class="list-group-item">Scheduled Cron Tasks</a>
|
||||
|
||||
<a href="#" class="list-group-item disabled">Network Management</a>
|
||||
|
||||
<a href="/{{NAME}}/networking/dns/" class="list-group-item">DNS Configuration</a>
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
|
||||
"application-deployment": "deployment/application-deployment/",
|
||||
"checks-examples": "deployment/zero-downtime-deploys/",
|
||||
"process-management": "deployment/process-management/",
|
||||
"remote-commands": "deployment/remote-commands/",
|
||||
|
||||
"process-management": "processes/process-management/",
|
||||
"deployment/process-management": "processes/process-management/",
|
||||
"deployment/one-off-processes": "processes/deployment/one-off-tasks/",
|
||||
|
||||
"deployment/buildpacks": "deployment/methods/herokuish-buildpacks/",
|
||||
"deployment/methods/buildpacks": "deployment/methods/herokuish-buildpacks/",
|
||||
"deployment/dockerfiles": "deployment/methods/dockerfiles/",
|
||||
|
||||
21
dokku
21
dokku
@@ -42,6 +42,7 @@ DOKKU_DISTRO=$(
|
||||
export DOCKER_BIN=${DOCKER_BIN:="docker"}
|
||||
|
||||
export DOKKU_IMAGE=${DOKKU_IMAGE:="gliderlabs/herokuish:latest"}
|
||||
export DOKKU_CNB_BUILDER=${DOKKU_CNB_BUILDER:="heroku/buildpacks"}
|
||||
export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"}
|
||||
|
||||
export PLUGIN_PATH=${PLUGIN_PATH:="$DOKKU_LIB_ROOT/plugins"}
|
||||
@@ -88,10 +89,13 @@ if [[ "${args[0]}" =~ ^--.* ]]; then
|
||||
fi
|
||||
! has_tty && DOKKU_QUIET_OUTPUT=1
|
||||
|
||||
if [[ $(id -un) != "dokku" ]] && [[ ! $1 =~ plugin:* ]] && [[ $1 != "ssh-keys:add" ]] && [[ $1 != "ssh-keys:remove" ]]; then
|
||||
export SSH_USER=$(id -un)
|
||||
sudo -u dokku -E -H "$0" "$@"
|
||||
exit $?
|
||||
if [[ $(id -un) != "dokku" ]]; then
|
||||
unset TMP TMPDIR TEMP TEMPDIR
|
||||
if [[ ! $1 =~ plugin:* ]] && [[ $1 != "ssh-keys:add" ]] && [[ $1 != "ssh-keys:remove" ]]; then
|
||||
export SSH_USER=$(id -un)
|
||||
sudo -u dokku -E -H "$0" "$@"
|
||||
exit $?
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $1 =~ ^plugin:.* && $1 != "plugin:help" && $1 != "plugin:list" ]] || [[ $1 == "ssh-keys:add" ]] || [[ $1 == "ssh-keys:remove" ]]; then
|
||||
@@ -237,14 +241,7 @@ case "$1" in
|
||||
;;
|
||||
|
||||
version | -v | --version)
|
||||
if [[ -f "$DOKKU_LIB_ROOT/STABLE_VERSION" ]]; then
|
||||
DOKKU_VERSION=$(cat "${DOKKU_LIB_ROOT}/STABLE_VERSION")
|
||||
elif [[ -f "$DOKKU_LIB_ROOT/VERSION" ]]; then
|
||||
DOKKU_VERSION=$(cat "${DOKKU_LIB_ROOT}/VERSION")
|
||||
else
|
||||
dokku_log_fail "Unable to determine dokku's version"
|
||||
fi
|
||||
echo "dokku version ${DOKKU_VERSION}"
|
||||
dokku_version
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core standard plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -9,6 +9,10 @@ cmd-report() {
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP="$1"
|
||||
|
||||
if [[ "$APP" == "--format" ]]; then
|
||||
dokku_log_fail "--format flag not supported on global report"
|
||||
fi
|
||||
|
||||
dokku_log_info1 "uname: $(uname -a)"
|
||||
dokku_log_info1 "memory: "
|
||||
free -m | sed "s/^/ /"
|
||||
@@ -20,9 +24,10 @@ cmd-report() {
|
||||
dokku_log_info1 "sigil version: $(sigil -v)"
|
||||
dokku_log_info1 "herokuish version: "
|
||||
"$DOCKER_BIN" container run $DOKKU_GLOBAL_RUN_ARGS --rm "$DOKKU_IMAGE" herokuish version | sed "s/^/ /"
|
||||
dokku_log_info1 "dokku version: $(dokku version)"
|
||||
dokku_log_info1 "dokku version: $(dokku_version)"
|
||||
dokku_log_info1 "plugn version: $(plugn version)"
|
||||
dokku_log_info1 "dokku plugins: "
|
||||
dokku plugin:list | sed "s/^/ /"
|
||||
plugn list | sed "s/^/ /"
|
||||
|
||||
if [[ "$APP" == "--all" ]]; then
|
||||
for app in $(dokku_apps); do
|
||||
|
||||
@@ -8,11 +8,24 @@ cmd-run() {
|
||||
declare cmd="run"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP=""
|
||||
|
||||
local SCHEDULER_ID
|
||||
declare -a RUN_ENV
|
||||
RUN_ENV=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--cron-id=*)
|
||||
local arg=$(printf "%s" "$1" | sed -E 's/(^--cron-id=)//g')
|
||||
SCHEDULER_ID+=("$arg")
|
||||
shift
|
||||
;;
|
||||
--cron-id)
|
||||
if [[ ! $2 ]]; then
|
||||
dokku_log_warn "expected $1 to have an argument"
|
||||
break
|
||||
fi
|
||||
CRON_ID+=("$2")
|
||||
shift 2
|
||||
;;
|
||||
-e=* | --env=*)
|
||||
local arg=$(printf "%s" "$1" | sed -E 's/(^-e=)|(^--env=)//g')
|
||||
RUN_ENV+=("$arg")
|
||||
@@ -37,7 +50,7 @@ cmd-run() {
|
||||
verify_app_name "$APP"
|
||||
|
||||
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
|
||||
plugn trigger scheduler-run "$DOKKU_SCHEDULER" "$APP" "${#RUN_ENV[@]}" "${RUN_ENV[@]}" "$@"
|
||||
DOKKU_CRON_ID="$CRON_ID" plugn trigger scheduler-run "$DOKKU_SCHEDULER" "$APP" "${#RUN_ENV[@]}" "${RUN_ENV[@]}" "$@"
|
||||
}
|
||||
|
||||
cmd-run "$@"
|
||||
|
||||
1
plugins/20_events/cron-entries
Symbolic link
1
plugins/20_events/cron-entries
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/cron-write
Symbolic link
1
plugins/20_events/cron-write
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core events logging plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
1
plugins/20_events/scheduler-register-retired
Symbolic link
1
plugins/20_events/scheduler-register-retired
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/20_events/storage-list
Symbolic link
1
plugins/20_events/storage-list
Symbolic link
@@ -0,0 +1 @@
|
||||
hook
|
||||
1
plugins/app-json/.gitignore
vendored
1
plugins/app-json/.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
/triggers
|
||||
/pre-*
|
||||
/post-*
|
||||
/install
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
TRIGGERS = triggers/post-deploy triggers/pre-deploy
|
||||
TRIGGERS = triggers/install triggers/post-delete triggers/post-deploy triggers/pre-deploy
|
||||
BUILD = triggers
|
||||
PLUGIN_NAME = app-json
|
||||
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
package appjson
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
shellquote "github.com/kballard/go-shellquote"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// AppJSON is a struct that represents an app.json file as understood by Dokku
|
||||
type AppJSON struct {
|
||||
Cron []CronCommand `json:"cron"`
|
||||
Scripts struct {
|
||||
Dokku struct {
|
||||
Predeploy string `json:"predeploy"`
|
||||
@@ -25,382 +17,18 @@ type AppJSON struct {
|
||||
} `json:"scripts"`
|
||||
}
|
||||
|
||||
func constructScript(command string, shell string, isHerokuishImage bool, hasEntrypoint bool) []string {
|
||||
if hasEntrypoint {
|
||||
words, err := shellquote.Split(strings.TrimSpace(command))
|
||||
if err != nil {
|
||||
common.LogWarn(fmt.Sprintf("Skipping command construction for app with ENTRYPOINT: %v", err.Error()))
|
||||
return nil
|
||||
}
|
||||
return words
|
||||
}
|
||||
|
||||
script := []string{"set -eo pipefail;"}
|
||||
if os.Getenv("DOKKU_TRACE") == "1" {
|
||||
script = append(script, "set -x;")
|
||||
}
|
||||
|
||||
if isHerokuishImage {
|
||||
script = append(script, []string{
|
||||
"if [[ -d '/app' ]]; then",
|
||||
" export HOME=/app;",
|
||||
" cd $HOME;",
|
||||
"fi;",
|
||||
"if [[ -d '/app/.profile.d' ]]; then",
|
||||
" for file in /app/.profile.d/*; do source $file; done;",
|
||||
"fi;",
|
||||
|
||||
"if [[ -d '/cache' ]]; then",
|
||||
" rm -rf /tmp/cache ;",
|
||||
" ln -sf /cache /tmp/cache;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
if strings.HasPrefix(command, "/") {
|
||||
commandBin := strings.Split(command, " ")[0]
|
||||
script = append(script, []string{
|
||||
fmt.Sprintf("if [[ ! -x \"%s\" ]]; then", commandBin),
|
||||
" echo specified binary is not executable;",
|
||||
" exit 1;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
script = append(script, fmt.Sprintf("%s || exit 1;", command))
|
||||
|
||||
if isHerokuishImage {
|
||||
script = append(script, []string{
|
||||
"if [[ -d '/cache' ]]; then",
|
||||
" rm -f /tmp/cache;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
return []string{shell, "-c", strings.Join(script, " ")}
|
||||
// CronCommand is a struct that represents a single cron command from an app.json file
|
||||
type CronCommand struct {
|
||||
Command string `json:"command"`
|
||||
Schedule string `json:"schedule"`
|
||||
}
|
||||
|
||||
// getPhaseScript extracts app.json from app image and returns the appropriate json key/value
|
||||
func getPhaseScript(appName string, image string, phase string) (string, error) {
|
||||
appJSONFile, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("dokku-%s-%s", common.MustGetEnv("DOKKU_PID"), "getPhaseScript"))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Cannot create temporary file: %v", err)
|
||||
}
|
||||
|
||||
defer os.Remove(appJSONFile.Name())
|
||||
|
||||
common.CopyFromImage(appName, image, "app.json", appJSONFile.Name())
|
||||
if !common.FileExists(appJSONFile.Name()) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(appJSONFile.Name())
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Cannot read app.json file: %v", err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(string(b)) == "" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var appJSON AppJSON
|
||||
if err = json.Unmarshal(b, &appJSON); err != nil {
|
||||
return "", fmt.Errorf("Cannot parse app.json: %v", err)
|
||||
}
|
||||
|
||||
if phase == "predeploy" {
|
||||
return appJSON.Scripts.Dokku.Predeploy, nil
|
||||
}
|
||||
|
||||
return appJSON.Scripts.Dokku.Postdeploy, nil
|
||||
// GetAppjsonDirectory returns the directory containing a given app's extracted app.json file
|
||||
func GetAppjsonDirectory(appName string) string {
|
||||
return filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "app-json", appName)
|
||||
}
|
||||
|
||||
// getReleaseCommand extracts the release command from a given app's procfile
|
||||
func getReleaseCommand(appName string, image string) string {
|
||||
err := common.SuppressOutput(func() error {
|
||||
return common.PlugnTrigger("procfile-extract", []string{appName, image}...)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
processType := "release"
|
||||
port := "5000"
|
||||
b, _ := common.PlugnTriggerOutput("procfile-get-command", []string{appName, processType, port}...)
|
||||
return strings.TrimSpace(string(b[:]))
|
||||
}
|
||||
|
||||
func getDokkuAppShell(appName string) string {
|
||||
shell := "/bin/bash"
|
||||
globalShell := ""
|
||||
appShell := ""
|
||||
|
||||
ctx := context.Background()
|
||||
errs, ctx := errgroup.WithContext(ctx)
|
||||
errs.Go(func() error {
|
||||
b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_APP_SHELL"}...)
|
||||
globalShell = strings.TrimSpace(string(b[:]))
|
||||
return nil
|
||||
})
|
||||
errs.Go(func() error {
|
||||
b, _ := common.PlugnTriggerOutput("config-global", []string{"DOKKU_APP_SHELL"}...)
|
||||
appShell = strings.TrimSpace(string(b[:]))
|
||||
return nil
|
||||
})
|
||||
|
||||
errs.Wait()
|
||||
if appShell != "" {
|
||||
shell = appShell
|
||||
} else if globalShell != "" {
|
||||
shell = globalShell
|
||||
}
|
||||
|
||||
return shell
|
||||
}
|
||||
|
||||
func executeScript(appName string, imageTag string, phase string) error {
|
||||
common.LogInfo1(fmt.Sprintf("Checking for %s task", phase))
|
||||
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
command := ""
|
||||
phaseSource := ""
|
||||
if phase == "release" {
|
||||
command = getReleaseCommand(appName, image)
|
||||
phaseSource = "Procfile"
|
||||
} else {
|
||||
var err error
|
||||
phaseSource = "app.json"
|
||||
if command, err = getPhaseScript(appName, image, phase); err != nil {
|
||||
common.LogExclaim(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if command == "" {
|
||||
common.LogVerbose(fmt.Sprintf("No %s task found, skipping", phase))
|
||||
return nil
|
||||
}
|
||||
|
||||
common.LogInfo1(fmt.Sprintf("Executing %s task from %s: %s", phase, phaseSource, command))
|
||||
isHerokuishImage := common.IsImageHerokuishBased(image, appName)
|
||||
dockerfileEntrypoint := ""
|
||||
dockerfileCommand := ""
|
||||
if !isHerokuishImage {
|
||||
dockerfileEntrypoint, _ = getEntrypointFromImage(image)
|
||||
dockerfileCommand, _ = getCommandFromImage(image)
|
||||
}
|
||||
|
||||
hasEntrypoint := dockerfileEntrypoint != ""
|
||||
dokkuAppShell := getDokkuAppShell(appName)
|
||||
script := constructScript(command, dokkuAppShell, isHerokuishImage, hasEntrypoint)
|
||||
|
||||
imageSourceType := "dockerfile"
|
||||
if isHerokuishImage {
|
||||
imageSourceType = "herokuish"
|
||||
}
|
||||
|
||||
cacheDir := fmt.Sprintf("%s/cache", common.AppRoot(appName))
|
||||
cacheHostDir := fmt.Sprintf("%s/cache", common.AppHostRoot(appName))
|
||||
if !common.DirectoryExists(cacheDir) {
|
||||
os.MkdirAll(cacheDir, 0755)
|
||||
}
|
||||
|
||||
var dockerArgs []string
|
||||
if b, err := common.PlugnTriggerSetup("docker-args-deploy", []string{appName, imageTag}...).SetInput("").Output(); err == nil {
|
||||
words, err := shellquote.Split(strings.TrimSpace(string(b[:])))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, words...)
|
||||
}
|
||||
|
||||
if b, err := common.PlugnTriggerSetup("docker-args-process-deploy", []string{appName, imageSourceType, imageTag}...).SetInput("").Output(); err == nil {
|
||||
words, err := shellquote.Split(strings.TrimSpace(string(b[:])))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, words...)
|
||||
}
|
||||
|
||||
filteredArgs := []string{"restart", "cpus", "memory", "memory-swap", "memory-reservation", "gpus"}
|
||||
for _, filteredArg := range filteredArgs {
|
||||
// re := regexp.MustCompile("--" + filteredArg + "=[0-9A-Za-z!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]+ ")
|
||||
|
||||
var filteredDockerArgs []string
|
||||
for _, dockerArg := range dockerArgs {
|
||||
if !strings.HasPrefix(dockerArg, "--"+filteredArg+"=") {
|
||||
filteredDockerArgs = append(filteredDockerArgs, dockerArg)
|
||||
}
|
||||
}
|
||||
|
||||
dockerArgs = filteredDockerArgs
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, "--label=dokku_phase_script="+phase)
|
||||
dockerArgs = append(dockerArgs, "-v", cacheHostDir+":/cache")
|
||||
if os.Getenv("DOKKU_TRACE") != "" {
|
||||
dockerArgs = append(dockerArgs, "--env", "DOKKU_TRACE="+os.Getenv("DOKKU_TRACE"))
|
||||
}
|
||||
|
||||
containerID, err := createdContainerID(appName, dockerArgs, image, script, phase)
|
||||
if err != nil {
|
||||
common.LogFail(fmt.Sprintf("Failed to create %s execution container: %s", phase, err.Error()))
|
||||
}
|
||||
|
||||
if !waitForExecution(containerID) {
|
||||
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogVerboseQuietContainerLogs(containerID)
|
||||
common.LogInfo2Quiet(fmt.Sprintf("End of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogFail(fmt.Sprintf("Execution of %s task failed: %s", phase, command))
|
||||
}
|
||||
|
||||
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogVerboseQuietContainerLogs(containerID)
|
||||
common.LogInfo2Quiet(fmt.Sprintf("End of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
|
||||
if phase != "predeploy" {
|
||||
return nil
|
||||
}
|
||||
|
||||
commitArgs := []string{"container", "commit"}
|
||||
if !isHerokuishImage {
|
||||
if dockerfileEntrypoint != "" {
|
||||
commitArgs = append(commitArgs, "--change", dockerfileEntrypoint)
|
||||
}
|
||||
|
||||
if dockerfileCommand != "" {
|
||||
commitArgs = append(commitArgs, "--change", dockerfileCommand)
|
||||
}
|
||||
}
|
||||
|
||||
commitArgs = append(commitArgs, []string{
|
||||
"--change",
|
||||
"LABEL org.label-schema.schema-version=1.0",
|
||||
"--change",
|
||||
"LABEL org.label-schema.vendor=dokku",
|
||||
"--change",
|
||||
fmt.Sprintf("LABEL com.dokku.app-name=%s", appName),
|
||||
"--change",
|
||||
fmt.Sprintf("LABEL com.dokku.%s-phase=true", phase),
|
||||
}...)
|
||||
commitArgs = append(commitArgs, containerID, image)
|
||||
containerCommitCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
commitArgs...,
|
||||
)
|
||||
containerCommitCmd.ShowOutput = false
|
||||
containerCommitCmd.Command.Stderr = os.Stderr
|
||||
if !containerCommitCmd.Execute() {
|
||||
common.LogFail(fmt.Sprintf("Commiting of '%s' to image failed: %s", phase, command))
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...)
|
||||
}
|
||||
|
||||
func getEntrypointFromImage(image string) (string, error) {
|
||||
output, err := common.DockerInspect(image, "{{json .Config.Entrypoint}}")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if output == "null" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var entrypoint []string
|
||||
if err = json.Unmarshal([]byte(output), &entrypoint); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(entrypoint) == 3 && entrypoint[0] == "/bin/sh" && entrypoint[1] == "-c" {
|
||||
return fmt.Sprintf("ENTRYPOINT %s", entrypoint[2]), nil
|
||||
}
|
||||
|
||||
serializedEntrypoint, err := json.Marshal(entrypoint)
|
||||
return fmt.Sprintf("ENTRYPOINT %s", string(serializedEntrypoint)), err
|
||||
}
|
||||
|
||||
func getCommandFromImage(image string) (string, error) {
|
||||
output, err := common.DockerInspect(image, "{{json .Config.Cmd}}")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if output == "null" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var command []string
|
||||
if err = json.Unmarshal([]byte(output), &command); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(command) == 3 && command[0] == "/bin/sh" && command[1] == "-c" {
|
||||
return fmt.Sprintf("CMD %s", command[2]), nil
|
||||
}
|
||||
|
||||
serializedEntrypoint, err := json.Marshal(command)
|
||||
return fmt.Sprintf("CMD %s", string(serializedEntrypoint)), err
|
||||
}
|
||||
|
||||
func waitForExecution(containerID string) bool {
|
||||
containerStartCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
"container",
|
||||
"start",
|
||||
containerID,
|
||||
)
|
||||
containerStartCmd.ShowOutput = false
|
||||
containerStartCmd.Command.Stderr = os.Stderr
|
||||
if !containerStartCmd.Execute() {
|
||||
return false
|
||||
}
|
||||
|
||||
containerWaitCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
"container",
|
||||
"wait",
|
||||
containerID,
|
||||
)
|
||||
|
||||
containerWaitCmd.ShowOutput = false
|
||||
containerWaitCmd.Command.Stderr = os.Stderr
|
||||
b, err := containerWaitCmd.Output()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
containerExitCode := strings.TrimSpace(string(b[:]))
|
||||
return containerExitCode == "0"
|
||||
}
|
||||
|
||||
func createdContainerID(appName string, dockerArgs []string, image string, command []string, phase string) (string, error) {
|
||||
runLabelArgs := fmt.Sprintf("--label=com.dokku.app-name=%s", appName)
|
||||
|
||||
arguments := strings.Split(common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS"), " ")
|
||||
arguments = append(arguments, runLabelArgs)
|
||||
arguments = append(arguments, dockerArgs...)
|
||||
|
||||
arguments = append([]string{"container", "create"}, arguments...)
|
||||
arguments = append(arguments, image)
|
||||
arguments = append(arguments, command...)
|
||||
|
||||
containerCreateCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
arguments...,
|
||||
)
|
||||
var stderr bytes.Buffer
|
||||
containerCreateCmd.ShowOutput = false
|
||||
containerCreateCmd.Command.Stderr = &stderr
|
||||
|
||||
b, err := containerCreateCmd.Output()
|
||||
if err != nil {
|
||||
return "", errors.New(stderr.String())
|
||||
}
|
||||
|
||||
containerID := strings.TrimSpace(string(b))
|
||||
err = common.PlugnTrigger("post-container-create", []string{"app", appName, containerID, phase}...)
|
||||
return containerID, err
|
||||
// GetAppjsonPath returns the path to a given app's extracted app.json file
|
||||
func GetAppjsonPath(appName string) string {
|
||||
return filepath.Join(GetAppjsonDirectory(appName), "app.json")
|
||||
}
|
||||
|
||||
409
plugins/app-json/functions.go
Normal file
409
plugins/app-json/functions.go
Normal file
@@ -0,0 +1,409 @@
|
||||
package appjson
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
shellquote "github.com/kballard/go-shellquote"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func constructScript(command string, shell string, isHerokuishImage bool, hasEntrypoint bool) []string {
|
||||
if hasEntrypoint {
|
||||
words, err := shellquote.Split(strings.TrimSpace(command))
|
||||
if err != nil {
|
||||
common.LogWarn(fmt.Sprintf("Skipping command construction for app with ENTRYPOINT: %v", err.Error()))
|
||||
return nil
|
||||
}
|
||||
return words
|
||||
}
|
||||
|
||||
script := []string{"set -eo pipefail;"}
|
||||
if os.Getenv("DOKKU_TRACE") == "1" {
|
||||
script = append(script, "set -x;")
|
||||
}
|
||||
|
||||
if isHerokuishImage {
|
||||
script = append(script, []string{
|
||||
"if [[ -d '/app' ]]; then",
|
||||
" export HOME=/app;",
|
||||
" cd $HOME;",
|
||||
"fi;",
|
||||
"if [[ -d '/app/.profile.d' ]]; then",
|
||||
" for file in /app/.profile.d/*; do source $file; done;",
|
||||
"fi;",
|
||||
|
||||
"if [[ -d '/cache' ]]; then",
|
||||
" rm -rf /tmp/cache ;",
|
||||
" ln -sf /cache /tmp/cache;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
if strings.HasPrefix(command, "/") {
|
||||
commandBin := strings.Split(command, " ")[0]
|
||||
script = append(script, []string{
|
||||
fmt.Sprintf("if [[ ! -x \"%s\" ]]; then", commandBin),
|
||||
" echo specified binary is not executable;",
|
||||
" exit 1;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
script = append(script, fmt.Sprintf("%s || exit 1;", command))
|
||||
|
||||
if isHerokuishImage {
|
||||
script = append(script, []string{
|
||||
"if [[ -d '/cache' ]]; then",
|
||||
" rm -f /tmp/cache;",
|
||||
"fi;",
|
||||
}...)
|
||||
}
|
||||
|
||||
return []string{shell, "-c", strings.Join(script, " ")}
|
||||
}
|
||||
|
||||
// getPhaseScript extracts app.json from app image and returns the appropriate json key/value
|
||||
func getPhaseScript(appName string, phase string) (string, error) {
|
||||
if !common.FileExists(GetAppjsonPath(appName)) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(GetAppjsonPath(appName))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Cannot read app.json file: %v", err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(string(b)) == "" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
var appJSON AppJSON
|
||||
if err = json.Unmarshal(b, &appJSON); err != nil {
|
||||
return "", fmt.Errorf("Cannot parse app.json: %v", err)
|
||||
}
|
||||
|
||||
if phase == "predeploy" {
|
||||
return appJSON.Scripts.Dokku.Predeploy, nil
|
||||
}
|
||||
|
||||
return appJSON.Scripts.Dokku.Postdeploy, nil
|
||||
}
|
||||
|
||||
// getReleaseCommand extracts the release command from a given app's procfile
|
||||
func getReleaseCommand(appName string, image string) string {
|
||||
err := common.SuppressOutput(func() error {
|
||||
return common.PlugnTrigger("procfile-extract", []string{appName, image}...)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
processType := "release"
|
||||
port := "5000"
|
||||
b, _ := common.PlugnTriggerOutput("procfile-get-command", []string{appName, processType, port}...)
|
||||
return strings.TrimSpace(string(b[:]))
|
||||
}
|
||||
|
||||
func getDokkuAppShell(appName string) string {
|
||||
shell := "/bin/bash"
|
||||
globalShell := ""
|
||||
appShell := ""
|
||||
|
||||
ctx := context.Background()
|
||||
errs, ctx := errgroup.WithContext(ctx)
|
||||
errs.Go(func() error {
|
||||
b, _ := common.PlugnTriggerOutput("config-get-global", []string{"DOKKU_APP_SHELL"}...)
|
||||
globalShell = strings.TrimSpace(string(b[:]))
|
||||
return nil
|
||||
})
|
||||
errs.Go(func() error {
|
||||
b, _ := common.PlugnTriggerOutput("config-get", []string{"DOKKU_APP_SHELL", appName}...)
|
||||
appShell = strings.TrimSpace(string(b[:]))
|
||||
return nil
|
||||
})
|
||||
|
||||
errs.Wait()
|
||||
if appShell != "" {
|
||||
shell = appShell
|
||||
} else if globalShell != "" {
|
||||
shell = globalShell
|
||||
}
|
||||
|
||||
return shell
|
||||
}
|
||||
|
||||
func executeScript(appName string, image string, imageTag string, phase string) error {
|
||||
common.LogInfo1(fmt.Sprintf("Checking for %s task", phase))
|
||||
command := ""
|
||||
phaseSource := ""
|
||||
if phase == "release" {
|
||||
command = getReleaseCommand(appName, image)
|
||||
phaseSource = "Procfile"
|
||||
} else {
|
||||
var err error
|
||||
phaseSource = "app.json"
|
||||
if command, err = getPhaseScript(appName, phase); err != nil {
|
||||
common.LogExclaim(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if command == "" {
|
||||
common.LogVerbose(fmt.Sprintf("No %s task found, skipping", phase))
|
||||
return nil
|
||||
}
|
||||
|
||||
common.LogInfo1(fmt.Sprintf("Executing %s task from %s: %s", phase, phaseSource, command))
|
||||
isHerokuishImage := common.IsImageHerokuishBased(image, appName)
|
||||
dockerfileEntrypoint := ""
|
||||
dockerfileCommand := ""
|
||||
if !isHerokuishImage {
|
||||
dockerfileEntrypoint, _ = getEntrypointFromImage(image)
|
||||
dockerfileCommand, _ = getCommandFromImage(image)
|
||||
}
|
||||
|
||||
hasEntrypoint := dockerfileEntrypoint != ""
|
||||
dokkuAppShell := getDokkuAppShell(appName)
|
||||
script := constructScript(command, dokkuAppShell, isHerokuishImage, hasEntrypoint)
|
||||
|
||||
imageSourceType := "dockerfile"
|
||||
if isHerokuishImage {
|
||||
imageSourceType = "herokuish"
|
||||
}
|
||||
|
||||
cacheDir := fmt.Sprintf("%s/cache", common.AppRoot(appName))
|
||||
cacheHostDir := fmt.Sprintf("%s/cache", common.AppHostRoot(appName))
|
||||
if !common.DirectoryExists(cacheDir) {
|
||||
os.MkdirAll(cacheDir, 0755)
|
||||
}
|
||||
|
||||
var dockerArgs []string
|
||||
if b, err := common.PlugnTriggerSetup("docker-args-deploy", []string{appName, imageTag}...).SetInput("").Output(); err == nil {
|
||||
words, err := shellquote.Split(strings.TrimSpace(string(b[:])))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, words...)
|
||||
}
|
||||
|
||||
if b, err := common.PlugnTriggerSetup("docker-args-process-deploy", []string{appName, imageSourceType, imageTag}...).SetInput("").Output(); err == nil {
|
||||
words, err := shellquote.Split(strings.TrimSpace(string(b[:])))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, words...)
|
||||
}
|
||||
|
||||
filteredArgs := []string{"restart", "cpus", "memory", "memory-swap", "memory-reservation", "gpus"}
|
||||
for _, filteredArg := range filteredArgs {
|
||||
// re := regexp.MustCompile("--" + filteredArg + "=[0-9A-Za-z!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]+ ")
|
||||
|
||||
var filteredDockerArgs []string
|
||||
for _, dockerArg := range dockerArgs {
|
||||
if !strings.HasPrefix(dockerArg, "--"+filteredArg+"=") {
|
||||
filteredDockerArgs = append(filteredDockerArgs, dockerArg)
|
||||
}
|
||||
}
|
||||
|
||||
dockerArgs = filteredDockerArgs
|
||||
}
|
||||
|
||||
dockerArgs = append(dockerArgs, "--label=dokku_phase_script="+phase)
|
||||
dockerArgs = append(dockerArgs, "-v", cacheHostDir+":/cache")
|
||||
if os.Getenv("DOKKU_TRACE") != "" {
|
||||
dockerArgs = append(dockerArgs, "--env", "DOKKU_TRACE="+os.Getenv("DOKKU_TRACE"))
|
||||
}
|
||||
|
||||
containerID, err := createdContainerID(appName, dockerArgs, image, script, phase)
|
||||
if err != nil {
|
||||
common.LogFail(fmt.Sprintf("Failed to create %s execution container: %s", phase, err.Error()))
|
||||
}
|
||||
|
||||
if !waitForExecution(containerID) {
|
||||
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogVerboseQuietContainerLogs(containerID)
|
||||
common.LogInfo2Quiet(fmt.Sprintf("End of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogFail(fmt.Sprintf("Execution of %s task failed: %s", phase, command))
|
||||
}
|
||||
|
||||
common.LogInfo2Quiet(fmt.Sprintf("Start of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
common.LogVerboseQuietContainerLogs(containerID)
|
||||
common.LogInfo2Quiet(fmt.Sprintf("End of %s %s task (%s) output", appName, phase, containerID[0:9]))
|
||||
|
||||
if phase != "predeploy" {
|
||||
return nil
|
||||
}
|
||||
|
||||
commitArgs := []string{"container", "commit"}
|
||||
if !isHerokuishImage {
|
||||
if dockerfileEntrypoint != "" {
|
||||
commitArgs = append(commitArgs, "--change", dockerfileEntrypoint)
|
||||
}
|
||||
|
||||
if dockerfileCommand != "" {
|
||||
commitArgs = append(commitArgs, "--change", dockerfileCommand)
|
||||
}
|
||||
}
|
||||
|
||||
commitArgs = append(commitArgs, []string{
|
||||
"--change",
|
||||
"LABEL org.label-schema.schema-version=1.0",
|
||||
"--change",
|
||||
"LABEL org.label-schema.vendor=dokku",
|
||||
"--change",
|
||||
fmt.Sprintf("LABEL com.dokku.app-name=%s", appName),
|
||||
"--change",
|
||||
fmt.Sprintf("LABEL com.dokku.%s-phase=true", phase),
|
||||
}...)
|
||||
commitArgs = append(commitArgs, containerID, image)
|
||||
containerCommitCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
commitArgs...,
|
||||
)
|
||||
containerCommitCmd.ShowOutput = false
|
||||
containerCommitCmd.Command.Stderr = os.Stderr
|
||||
if !containerCommitCmd.Execute() {
|
||||
common.LogFail(fmt.Sprintf("Commiting of '%s' to image failed: %s", phase, command))
|
||||
}
|
||||
|
||||
return common.PlugnTrigger("scheduler-register-retired", []string{appName, containerID}...)
|
||||
}
|
||||
|
||||
func getEntrypointFromImage(image string) (string, error) {
|
||||
output, err := common.DockerInspect(image, "{{json .Config.Entrypoint}}")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if output == "null" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var entrypoint []string
|
||||
if err = json.Unmarshal([]byte(output), &entrypoint); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(entrypoint) == 3 && entrypoint[0] == "/bin/sh" && entrypoint[1] == "-c" {
|
||||
return fmt.Sprintf("ENTRYPOINT %s", entrypoint[2]), nil
|
||||
}
|
||||
|
||||
serializedEntrypoint, err := json.Marshal(entrypoint)
|
||||
return fmt.Sprintf("ENTRYPOINT %s", string(serializedEntrypoint)), err
|
||||
}
|
||||
|
||||
func getCommandFromImage(image string) (string, error) {
|
||||
output, err := common.DockerInspect(image, "{{json .Config.Cmd}}")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if output == "null" {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var command []string
|
||||
if err = json.Unmarshal([]byte(output), &command); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(command) == 3 && command[0] == "/bin/sh" && command[1] == "-c" {
|
||||
return fmt.Sprintf("CMD %s", command[2]), nil
|
||||
}
|
||||
|
||||
serializedEntrypoint, err := json.Marshal(command)
|
||||
return fmt.Sprintf("CMD %s", string(serializedEntrypoint)), err
|
||||
}
|
||||
|
||||
func waitForExecution(containerID string) bool {
|
||||
containerStartCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
"container",
|
||||
"start",
|
||||
containerID,
|
||||
)
|
||||
containerStartCmd.ShowOutput = false
|
||||
containerStartCmd.Command.Stderr = os.Stderr
|
||||
if !containerStartCmd.Execute() {
|
||||
return false
|
||||
}
|
||||
|
||||
containerWaitCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
"container",
|
||||
"wait",
|
||||
containerID,
|
||||
)
|
||||
|
||||
containerWaitCmd.ShowOutput = false
|
||||
containerWaitCmd.Command.Stderr = os.Stderr
|
||||
b, err := containerWaitCmd.Output()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
containerExitCode := strings.TrimSpace(string(b[:]))
|
||||
return containerExitCode == "0"
|
||||
}
|
||||
|
||||
func createdContainerID(appName string, dockerArgs []string, image string, command []string, phase string) (string, error) {
|
||||
runLabelArgs := fmt.Sprintf("--label=com.dokku.app-name=%s", appName)
|
||||
|
||||
arguments := strings.Split(common.MustGetEnv("DOKKU_GLOBAL_RUN_ARGS"), " ")
|
||||
arguments = append(arguments, runLabelArgs)
|
||||
arguments = append(arguments, dockerArgs...)
|
||||
|
||||
arguments = append([]string{"container", "create"}, arguments...)
|
||||
arguments = append(arguments, image)
|
||||
arguments = append(arguments, command...)
|
||||
|
||||
containerCreateCmd := common.NewShellCmdWithArgs(
|
||||
common.DockerBin(),
|
||||
arguments...,
|
||||
)
|
||||
var stderr bytes.Buffer
|
||||
containerCreateCmd.ShowOutput = false
|
||||
containerCreateCmd.Command.Stderr = &stderr
|
||||
|
||||
b, err := containerCreateCmd.Output()
|
||||
if err != nil {
|
||||
return "", errors.New(stderr.String())
|
||||
}
|
||||
|
||||
containerID := strings.TrimSpace(string(b))
|
||||
err = common.PlugnTrigger("post-container-create", []string{"app", appName, containerID, phase}...)
|
||||
return containerID, err
|
||||
}
|
||||
|
||||
func refreshAppJSON(appName string, image string) error {
|
||||
baseDirectory := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "app-json")
|
||||
if !common.DirectoryExists(baseDirectory) {
|
||||
return errors.New("Run 'dokku plugin:install' to ensure the correct directories exist")
|
||||
}
|
||||
|
||||
directory := GetAppjsonDirectory(appName)
|
||||
if !common.DirectoryExists(directory) {
|
||||
if err := os.MkdirAll(directory, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
appjsonPath := GetAppjsonPath(appName)
|
||||
if common.FileExists(appjsonPath) {
|
||||
if err := os.Remove(appjsonPath); err != nil {
|
||||
return errors.New("Unable to remove previous app.json file")
|
||||
}
|
||||
}
|
||||
|
||||
common.CopyFromImage(appName, image, "app.json", appjsonPath)
|
||||
return nil
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core app-json plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/app-json"
|
||||
appjson "github.com/dokku/dokku/plugins/app-json"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
@@ -18,6 +18,11 @@ func main() {
|
||||
|
||||
var err error
|
||||
switch trigger {
|
||||
case "install":
|
||||
err = appjson.TriggerInstall()
|
||||
case "post-delete":
|
||||
appName := flag.Arg(0)
|
||||
err = appjson.TriggerPostDelete(appName)
|
||||
case "post-deploy":
|
||||
appName := flag.Arg(0)
|
||||
imageTag := flag.Arg(3)
|
||||
|
||||
@@ -1,8 +1,47 @@
|
||||
package appjson
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// TriggerInstall initializes app restart policies
|
||||
func TriggerInstall() error {
|
||||
directory := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "app-json")
|
||||
if err := os.MkdirAll(directory, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := common.SetPermissions(directory, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerPostDelete destroys the app-json data for a given app container
|
||||
func TriggerPostDelete(appName string) error {
|
||||
directory := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "app-json", appName)
|
||||
dataErr := os.RemoveAll(directory)
|
||||
propertyErr := common.PropertyDestroy("app-json", appName)
|
||||
|
||||
if dataErr != nil {
|
||||
return dataErr
|
||||
}
|
||||
|
||||
return propertyErr
|
||||
}
|
||||
|
||||
// TriggerPostDeploy is a trigger to execute the postdeploy deployment task
|
||||
func TriggerPostDeploy(appName string, imageTag string) error {
|
||||
if err := executeScript(appName, imageTag, "postdeploy"); err != nil {
|
||||
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := executeScript(appName, image, imageTag, "postdeploy"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -10,11 +49,20 @@ func TriggerPostDeploy(appName string, imageTag string) error {
|
||||
|
||||
// TriggerPreDeploy is a trigger to execute predeploy and release deployment tasks
|
||||
func TriggerPreDeploy(appName string, imageTag string) error {
|
||||
if err := executeScript(appName, imageTag, "predeploy"); err != nil {
|
||||
image, err := common.GetDeployingAppImageName(appName, imageTag, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := executeScript(appName, imageTag, "release"); err != nil {
|
||||
if err := refreshAppJSON(appName, image); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := executeScript(appName, image, imageTag, "predeploy"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := executeScript(appName, image, imageTag, "release"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core apps plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
func ReportSingleApp(appName, infoFlag string) error {
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, flagKeys, trimPrefix, uppercaseFirstCharacter)
|
||||
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func reportDir(appName string) string {
|
||||
|
||||
@@ -65,11 +65,12 @@ func main() {
|
||||
err = apps.CommandRename(oldAppName, newAppName, *skipDeploy)
|
||||
case "report":
|
||||
args := flag.NewFlagSet("apps:report", flag.ExitOnError)
|
||||
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
||||
osArgs, infoFlag, flagErr := common.ParseReportArgs("apps", os.Args[2:])
|
||||
if flagErr == nil {
|
||||
args.Parse(osArgs)
|
||||
appName := args.Arg(0)
|
||||
err = apps.CommandReport(appName, infoFlag)
|
||||
err = apps.CommandReport(appName, *format, infoFlag)
|
||||
}
|
||||
case "unlock":
|
||||
args := flag.NewFlagSet("apps:unlock", flag.ExitOnError)
|
||||
|
||||
@@ -35,7 +35,7 @@ func main() {
|
||||
err = apps.TriggerPostDelete(appName)
|
||||
case "report":
|
||||
appName := flag.Arg(0)
|
||||
err = apps.ReportSingleApp(appName, "")
|
||||
err = apps.ReportSingleApp(appName, "", "")
|
||||
default:
|
||||
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
|
||||
}
|
||||
|
||||
@@ -175,21 +175,21 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error
|
||||
}
|
||||
|
||||
// CommandReport displays an app report for one or more apps
|
||||
func CommandReport(appName string, infoFlag string) error {
|
||||
func CommandReport(appName string, format string, infoFlag string) error {
|
||||
if len(appName) == 0 {
|
||||
apps, err := common.DokkuApps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, appName := range apps {
|
||||
if err := ReportSingleApp(appName, infoFlag); err != nil {
|
||||
if err := ReportSingleApp(appName, format, infoFlag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return ReportSingleApp(appName, infoFlag)
|
||||
return ReportSingleApp(appName, format, infoFlag)
|
||||
}
|
||||
|
||||
// CommandUnlock unlocks an app for deployment
|
||||
|
||||
@@ -13,6 +13,14 @@ trigger-builder-cnb-builder-build() {
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
local stack="$(plugn trigger buildpack-stack-name "$APP")"
|
||||
if [[ -z "$stack" ]]; then
|
||||
DOKKU_CNB_STACK="$stack"
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Building $APP from cnb stack $DOKKU_CNB_STACK (experimental)..."
|
||||
|
||||
if ! command -v "pack" &>/dev/null; then
|
||||
dokku_log_fail "Missing pack, install it"
|
||||
fi
|
||||
@@ -28,7 +36,7 @@ trigger-builder-cnb-builder-build() {
|
||||
|
||||
plugn trigger pre-build-cnb "$APP" "$SOURCECODE_WORK_DIR"
|
||||
|
||||
pack build "$IMAGE" --builder heroku/buildpacks --path "$SOURCECODE_WORK_DIR" --default-process web
|
||||
pack build "$IMAGE" --builder "$DOKKU_CNB_BUILDER" --path "$SOURCECODE_WORK_DIR" --default-process web
|
||||
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=build --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP --label=dokku -t "$IMAGE" -
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ trigger-builder-cnb-builder-release() {
|
||||
plugn trigger pre-release-cnb "$APP" "$IMAGE_TAG"
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku -t "$IMAGE" -
|
||||
docker-image-labeler --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku "$IMAGE"
|
||||
plugn trigger post-release-cnb "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core builder-cnb plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -12,6 +12,8 @@ trigger-builder-dockerfile-builder-build() {
|
||||
return
|
||||
fi
|
||||
|
||||
dokku_log_info1 "Building $APP from Dockerfile"
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP")
|
||||
local DOCKER_BUILD_LABEL_ARGS="--label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=com.dokku.app-name=$APP"
|
||||
|
||||
|
||||
@@ -15,11 +15,7 @@ trigger-builder-dockerfile-builder-release() {
|
||||
plugn trigger pre-release-dockerfile "$APP" "$IMAGE_TAG"
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP" "$IMAGE_TAG")
|
||||
if "$DOCKER_BIN" image history --format "{{ json . }}" "$IMAGE" | grep -q "ONBUILD"; then
|
||||
dokku_log_warn "Image contains one or more ONBUILD directives, skipping label injection"
|
||||
else
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku -t "$IMAGE" -
|
||||
fi
|
||||
docker-image-labeler --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku "$IMAGE"
|
||||
plugn trigger post-release-dockerfile "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core builder-dockerfile plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -12,6 +12,14 @@ trigger-builder-herokuish-builder-build() {
|
||||
return
|
||||
fi
|
||||
|
||||
local stack="$(plugn trigger buildpack-stack-name "$APP")"
|
||||
if [[ -n "$stack" ]]; then
|
||||
dokku_log_info1 "Building $APP from $stack"
|
||||
DOKKU_IMAGE="$stack"
|
||||
else
|
||||
dokku_log_info1 "Building $APP from herokuish"
|
||||
fi
|
||||
|
||||
local IMAGE=$(get_app_image_name "$APP")
|
||||
local DOKKU_APP_CACHE_DIR="$DOKKU_ROOT/$APP/cache"
|
||||
local DOKKU_APP_HOST_CACHE_DIR="$DOKKU_HOST_ROOT/$APP/cache"
|
||||
@@ -22,8 +30,6 @@ trigger-builder-herokuish-builder-build() {
|
||||
pushd "$SOURCECODE_WORK_DIR" &>/dev/null
|
||||
|
||||
eval "$(config_export app "$APP")"
|
||||
|
||||
DOKKU_IMAGE="$(config_get "$APP" DOKKU_IMAGE || echo "$DOKKU_IMAGE")"
|
||||
plugn trigger builder-create-dokku-image "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR" "$DOKKU_IMAGE"
|
||||
NEW_DOKKU_IMAGE=$(plugn trigger builder-dokku-image "$BUILDER_TYPE" "$APP" "$SOURCECODE_WORK_DIR" "$DOKKU_IMAGE")
|
||||
[[ -n "$NEW_DOKKU_IMAGE" ]] && DOKKU_IMAGE="$NEW_DOKKU_IMAGE"
|
||||
|
||||
@@ -40,7 +40,7 @@ trigger-builder-herokuish-builder-release() {
|
||||
plugn trigger scheduler-register-retired "$APP" "$CID"
|
||||
fi
|
||||
|
||||
echo "FROM $IMAGE" | suppress_output "$DOCKER_BIN" image build --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku -t "$IMAGE" -
|
||||
docker-image-labeler --label=com.dokku.image-stage=release --label=com.dokku.app-name=$APP --label=org.label-schema.schema-version=1.0 --label=org.label-schema.vendor=dokku --label=dokku "$IMAGE"
|
||||
plugn trigger post-release-buildpack "$APP" "$IMAGE_TAG"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core builder-herokuish plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
1
plugins/buildpacks/.gitignore
vendored
1
plugins/buildpacks/.gitignore
vendored
@@ -2,6 +2,7 @@
|
||||
/subcommands/*
|
||||
/triggers/*
|
||||
/triggers
|
||||
/buildpack-stack-name
|
||||
/install
|
||||
/post-*
|
||||
/report
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
SUBCOMMANDS = subcommands/add subcommands/clear subcommands/list subcommands/remove subcommands/report subcommands/set
|
||||
TRIGGERS = triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/post-extract triggers/report
|
||||
SUBCOMMANDS = subcommands/add subcommands/clear subcommands/list subcommands/remove subcommands/report subcommands/set subcommands/set-property
|
||||
TRIGGERS = triggers/buildpack-stack-name triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/post-extract triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = buildpacks
|
||||
|
||||
|
||||
13
plugins/buildpacks/buildpacks.go
Normal file
13
plugins/buildpacks/buildpacks.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package buildpacks
|
||||
|
||||
var (
|
||||
// DefaultProperties is a map of all valid buildpacks properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"stack": "",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global buildpacks properties
|
||||
GlobalProperties = map[string]bool{
|
||||
"stack": true,
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core buildpacks plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
package buildpacks
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
func ReportSingleApp(appName, infoFlag string) error {
|
||||
// ReportSingleApp is an internal function that displays the buildpacks report for one or more apps
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--buildpacks-list": reportList,
|
||||
"--buildpacks-computed-stack": reportComputedStack,
|
||||
"--buildpacks-global-stack": reportGlobalStack,
|
||||
"--buildpacks-list": reportList,
|
||||
"--buildpacks-stack": reportStack,
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
@@ -24,7 +28,29 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("buildpacks", appName, infoFlag, infoFlags, flagKeys, trimPrefix, uppercaseFirstCharacter)
|
||||
return common.ReportSingleApp("buildpacks", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func reportComputedStack(appName string) string {
|
||||
if stack := common.PropertyGetDefault("buildpacks", appName, "stack", ""); stack != "" {
|
||||
return stack
|
||||
}
|
||||
|
||||
if stack := common.PropertyGetDefault("buildpacks", "--global", "stack", ""); stack != "" {
|
||||
return stack
|
||||
}
|
||||
|
||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_IMAGE"}...)
|
||||
if dokkuImage := strings.TrimSpace(string(b[:])); dokkuImage != "" {
|
||||
common.LogWarn("Deprecated: use buildpacks:set-property instead of specifying DOKKU_IMAGE environment variable")
|
||||
return dokkuImage
|
||||
}
|
||||
|
||||
return os.Getenv("DOKKU_IMAGE")
|
||||
}
|
||||
|
||||
func reportGlobalStack(appName string) string {
|
||||
return common.PropertyGetDefault("buildpacks", "--global", "stack", "")
|
||||
}
|
||||
|
||||
func reportList(appName string) string {
|
||||
@@ -35,3 +61,7 @@ func reportList(appName string) string {
|
||||
|
||||
return strings.Join(buildpacks, ",")
|
||||
}
|
||||
|
||||
func reportStack(appName string) string {
|
||||
return common.PropertyGetDefault("buildpacks", appName, "stack", "")
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ Additional commands:`
|
||||
buildpacks:remove <app> <buildpack>, Remove a buildpack set on the app
|
||||
buildpacks:report [<app>] [<flag>], Displays a buildpack report for one or more apps
|
||||
buildpacks:set [--index 1] <app> <buildpack>, Set new app buildpack at a given position defaulting to the first buildpack if no index is specified
|
||||
buildpacks:set-property [--global|<app>] <key> <value>, Set or clear a buildpacks property for an app
|
||||
`
|
||||
)
|
||||
|
||||
|
||||
@@ -44,11 +44,12 @@ func main() {
|
||||
err = buildpacks.CommandRemove(appName, buildpack, *index)
|
||||
case "report":
|
||||
args := flag.NewFlagSet("buildpacks:report", flag.ExitOnError)
|
||||
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
||||
osArgs, infoFlag, flagErr := common.ParseReportArgs("buildpacks", os.Args[2:])
|
||||
if flagErr == nil {
|
||||
args.Parse(osArgs)
|
||||
appName := args.Arg(0)
|
||||
err = buildpacks.CommandReport(appName, infoFlag)
|
||||
err = buildpacks.CommandReport(appName, *format, infoFlag)
|
||||
}
|
||||
case "set":
|
||||
args := flag.NewFlagSet("buildpacks:set", flag.ExitOnError)
|
||||
@@ -57,6 +58,19 @@ func main() {
|
||||
appName := args.Arg(0)
|
||||
buildpack := args.Arg(1)
|
||||
err = buildpacks.CommandSet(appName, buildpack, *index)
|
||||
case "set-property":
|
||||
args := flag.NewFlagSet("buildpacks:set-property", flag.ExitOnError)
|
||||
global := args.Bool("global", false, "--global: set a global property")
|
||||
args.Parse(os.Args[2:])
|
||||
appName := args.Arg(0)
|
||||
property := args.Arg(1)
|
||||
value := args.Arg(2)
|
||||
if *global {
|
||||
appName = "--global"
|
||||
property = args.Arg(0)
|
||||
value = args.Arg(1)
|
||||
}
|
||||
err = buildpacks.CommandSetProperty(appName, property, value)
|
||||
default:
|
||||
common.LogFail(fmt.Sprintf("Invalid plugin subcommand call: %s", subcommand))
|
||||
}
|
||||
|
||||
@@ -18,8 +18,11 @@ func main() {
|
||||
|
||||
var err error
|
||||
switch trigger {
|
||||
case "buildpack-stack-name":
|
||||
appName := flag.Arg(0)
|
||||
err = buildpacks.TriggerBuildpackStackName(appName)
|
||||
case "install":
|
||||
buildpacks.TriggerInstall()
|
||||
err = buildpacks.TriggerInstall()
|
||||
case "post-app-clone-setup":
|
||||
oldAppName := flag.Arg(0)
|
||||
newAppName := flag.Arg(1)
|
||||
@@ -30,14 +33,14 @@ func main() {
|
||||
err = buildpacks.TriggerPostAppRenameSetup(oldAppName, newAppName)
|
||||
case "post-delete":
|
||||
appName := flag.Arg(0)
|
||||
buildpacks.TriggerPostDelete(appName)
|
||||
err = buildpacks.TriggerPostDelete(appName)
|
||||
case "post-extract":
|
||||
appName := flag.Arg(0)
|
||||
sourceWorkDir := flag.Arg(1)
|
||||
buildpacks.TriggerPostExtract(appName, sourceWorkDir)
|
||||
err = buildpacks.TriggerPostExtract(appName, sourceWorkDir)
|
||||
case "report":
|
||||
appName := flag.Arg(0)
|
||||
err = buildpacks.ReportSingleApp(appName, "")
|
||||
err = buildpacks.ReportSingleApp(appName, "", "")
|
||||
default:
|
||||
common.LogFail(fmt.Sprintf("Invalid plugin trigger call: %s", trigger))
|
||||
}
|
||||
|
||||
@@ -104,21 +104,21 @@ func CommandRemove(appName string, buildpack string, index int) (err error) {
|
||||
}
|
||||
|
||||
// CommandReport displays a buildpacks report for one or more apps
|
||||
func CommandReport(appName string, infoFlag string) error {
|
||||
func CommandReport(appName string, format string, infoFlag string) error {
|
||||
if len(appName) == 0 {
|
||||
apps, err := common.DokkuApps()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, appName := range apps {
|
||||
if err := ReportSingleApp(appName, infoFlag); err != nil {
|
||||
if err := ReportSingleApp(appName, format, infoFlag); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return ReportSingleApp(appName, infoFlag)
|
||||
return ReportSingleApp(appName, format, infoFlag)
|
||||
}
|
||||
|
||||
// CommandSet implements buildpacks:set
|
||||
@@ -138,3 +138,18 @@ func CommandSet(appName string, buildpack string, index int) error {
|
||||
|
||||
return common.PropertyListSet("buildpacks", appName, "buildpacks", buildpack, index)
|
||||
}
|
||||
|
||||
// CommandSetProperty implements buildpacks:set-property
|
||||
func CommandSetProperty(appName string, property string, value string) error {
|
||||
oldStack := ""
|
||||
if property == "stack" {
|
||||
oldStack = common.PropertyGet("buildpacks", appName, "stack")
|
||||
}
|
||||
|
||||
common.CommandPropertySet("buildpacks", appName, property, value, DefaultProperties, GlobalProperties)
|
||||
if property == "stack" && oldStack != value {
|
||||
return common.PlugnTrigger("post-stack-set", []string{appName, value}...)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,15 +5,41 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// TriggerInstall runs the install step for the buildpacks plugin
|
||||
func TriggerInstall() {
|
||||
if err := common.PropertySetup("buildpacks"); err != nil {
|
||||
common.LogFail(fmt.Sprintf("Unable to install the buildpacks plugin: %s", err.Error()))
|
||||
// TriggerBuildpackStackName echos the stack name for the app
|
||||
func TriggerBuildpackStackName(appName string) error {
|
||||
if stack := common.PropertyGetDefault("buildpacks", appName, "stack", ""); stack != "" {
|
||||
fmt.Println(stack)
|
||||
return nil
|
||||
}
|
||||
|
||||
if stack := common.PropertyGetDefault("buildpacks", "--global", "stack", ""); stack != "" {
|
||||
fmt.Println(stack)
|
||||
return nil
|
||||
}
|
||||
|
||||
b, _ := common.PlugnTriggerOutput("config-get", []string{appName, "DOKKU_IMAGE"}...)
|
||||
dokkuImage := strings.TrimSpace(string(b[:]))
|
||||
if dokkuImage != "" {
|
||||
common.LogWarn("Deprecated: use buildpacks:set-property instead of specifying DOKKU_IMAGE environment variable")
|
||||
fmt.Println(dokkuImage)
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerInstall runs the install step for the buildpacks plugin
|
||||
func TriggerInstall() error {
|
||||
if err := common.PropertySetup("buildpacks"); err != nil {
|
||||
return fmt.Errorf("Unable to install the buildpacks plugin: %s", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriggerPostAppCloneSetup creates new buildpacks files
|
||||
@@ -40,29 +66,25 @@ func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
|
||||
}
|
||||
|
||||
// TriggerPostDelete destroys the buildpacks property for a given app container
|
||||
func TriggerPostDelete(appName string) {
|
||||
err := common.PropertyDestroy("buildpacks", appName)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
func TriggerPostDelete(appName string) error {
|
||||
return common.PropertyDestroy("buildpacks", appName)
|
||||
}
|
||||
|
||||
// TriggerPostExtract writes a .buildpacks file into the app
|
||||
func TriggerPostExtract(appName string, sourceWorkDir string) {
|
||||
func TriggerPostExtract(appName string, sourceWorkDir string) error {
|
||||
buildpacks, err := common.PropertyListGet("buildpacks", appName, "buildpacks")
|
||||
if err != nil {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(buildpacks) == 0 {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
buildpacksPath := filepath.Join(sourceWorkDir, ".buildpacks")
|
||||
file, err := os.OpenFile(buildpacksPath, os.O_RDWR|os.O_TRUNC|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
common.LogFail(fmt.Sprintf("Error writing .buildpacks file: %s", err.Error()))
|
||||
return
|
||||
return fmt.Errorf("Error writing .buildpacks file: %s", err.Error())
|
||||
}
|
||||
|
||||
w := bufio.NewWriter(file)
|
||||
@@ -71,8 +93,9 @@ func TriggerPostExtract(appName string, sourceWorkDir string) {
|
||||
}
|
||||
|
||||
if err = w.Flush(); err != nil {
|
||||
common.LogFail(fmt.Sprintf("Error writing .buildpacks file: %s", err.Error()))
|
||||
return
|
||||
return fmt.Errorf("Error writing .buildpacks file: %s", err.Error())
|
||||
}
|
||||
file.Chmod(0600)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core certificate management plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core checks plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -2,6 +2,7 @@ package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
@@ -305,7 +306,17 @@ func GetenvWithDefault(key string, defaultValue string) (val string) {
|
||||
func ParseReportArgs(pluginName string, arguments []string) ([]string, string, error) {
|
||||
osArgs := []string{}
|
||||
infoFlags := []string{}
|
||||
for _, argument := range arguments {
|
||||
skipNext := false
|
||||
for i, argument := range arguments {
|
||||
if skipNext {
|
||||
skipNext = false
|
||||
continue
|
||||
}
|
||||
if argument == "--format" {
|
||||
osArgs = append(osArgs, argument, arguments[i+1])
|
||||
skipNext = true
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(argument, "--") {
|
||||
infoFlags = append(infoFlags, argument)
|
||||
} else {
|
||||
@@ -323,7 +334,30 @@ func ParseReportArgs(pluginName string, arguments []string) ([]string, string, e
|
||||
}
|
||||
|
||||
// ReportSingleApp is an internal function that displays a report for an app
|
||||
func ReportSingleApp(reportType string, appName string, infoFlag string, infoFlags map[string]string, infoFlagKeys []string, trimPrefix bool, uppercaseFirstCharacter bool) error {
|
||||
func ReportSingleApp(reportType string, appName string, infoFlag string, infoFlags map[string]string, infoFlagKeys []string, format string, trimPrefix bool, uppercaseFirstCharacter bool) error {
|
||||
if format != "stdout" && infoFlag != "" {
|
||||
return errors.New("--format flag cannot be specified when specifying an info flag")
|
||||
}
|
||||
|
||||
if format == "json" {
|
||||
data := map[string]string{}
|
||||
for key, value := range infoFlags {
|
||||
prefix := "--"
|
||||
if trimPrefix {
|
||||
prefix = fmt.Sprintf("--%v-", reportType)
|
||||
}
|
||||
|
||||
// key = strings.Replace(strings.Replace(strings.TrimPrefix(key, prefix), "-", " ", -1), ".", " ", -1)
|
||||
data[strings.TrimPrefix(key, prefix)] = value
|
||||
}
|
||||
out, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Log(string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
flags := []string{}
|
||||
for key := range infoFlags {
|
||||
flags = append(flags, key)
|
||||
|
||||
@@ -17,6 +17,17 @@ dokku_apps() {
|
||||
[[ $INSTALLED_APPS ]] && echo "$INSTALLED_APPS"
|
||||
}
|
||||
|
||||
dokku_version() {
|
||||
if [[ -f "$DOKKU_LIB_ROOT/STABLE_VERSION" ]]; then
|
||||
DOKKU_VERSION=$(cat "${DOKKU_LIB_ROOT}/STABLE_VERSION")
|
||||
elif [[ -f "$DOKKU_LIB_ROOT/VERSION" ]]; then
|
||||
DOKKU_VERSION=$(cat "${DOKKU_LIB_ROOT}/VERSION")
|
||||
else
|
||||
dokku_log_fail "Unable to determine dokku's version"
|
||||
fi
|
||||
echo "dokku version ${DOKKU_VERSION}"
|
||||
}
|
||||
|
||||
dokku_log_quiet() {
|
||||
declare desc="log quiet formatter"
|
||||
if [[ -z "$DOKKU_QUIET_OUTPUT" ]]; then
|
||||
@@ -702,9 +713,6 @@ dokku_receive() {
|
||||
local DOKKU_CNB_EXPERIMENTAL="$(config_get "$APP" DOKKU_CNB_EXPERIMENTAL || true)"
|
||||
if [[ "$DOKKU_CNB_EXPERIMENTAL" == "1" ]]; then
|
||||
IMAGE_SOURCE_TYPE="cnb"
|
||||
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE (experimental)..."
|
||||
else
|
||||
dokku_log_info1 "Building $APP from $IMAGE_SOURCE_TYPE..."
|
||||
fi
|
||||
|
||||
DOKKU_QUIET_OUTPUT=1 config_set --no-restart "$APP" DOKKU_APP_TYPE="$IMAGE_SOURCE_TYPE"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core common plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -32,6 +33,7 @@ func CommandPropertySet(pluginName, appName, property, value string, properties
|
||||
validPropertyList[i] = properties[i].String()
|
||||
}
|
||||
|
||||
sort.Strings(validPropertyList)
|
||||
LogFail(fmt.Sprintf("Invalid property specified, valid properties include: %s", strings.Join(validPropertyList, ", ")))
|
||||
}
|
||||
|
||||
@@ -104,6 +106,16 @@ func PropertyGet(pluginName string, appName string, property string) string {
|
||||
func PropertyGetAll(pluginName string, appName string) (map[string]string, error) {
|
||||
properties := make(map[string]string)
|
||||
pluginAppConfigRoot := getPluginAppPropertyPath(pluginName, appName)
|
||||
|
||||
fi, err := os.Stat(pluginAppConfigRoot)
|
||||
if err != nil {
|
||||
return properties, nil
|
||||
}
|
||||
|
||||
if !fi.IsDir() {
|
||||
return properties, errors.New("Specified property path is not a directory")
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(pluginAppConfigRoot)
|
||||
if err != nil {
|
||||
return properties, err
|
||||
|
||||
@@ -75,6 +75,7 @@ func (sc *ShellCmd) CombinedOutput() ([]byte, error) {
|
||||
|
||||
// PlugnTrigger fire the given plugn trigger with the given args
|
||||
func PlugnTrigger(triggerName string, args ...string) error {
|
||||
LogDebug(fmt.Sprintf("plugn trigger %s %v", triggerName, args))
|
||||
return PlugnTriggerSetup(triggerName, args...).Run()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core config plugin"
|
||||
version = "0.22.9"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
|
||||
7
plugins/cron/.gitignore
vendored
Normal file
7
plugins/cron/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/commands
|
||||
/subcommands/*
|
||||
/triggers/*
|
||||
/triggers
|
||||
/cron-*
|
||||
/post-*
|
||||
/report
|
||||
6
plugins/cron/Makefile
Normal file
6
plugins/cron/Makefile
Normal file
@@ -0,0 +1,6 @@
|
||||
SUBCOMMANDS = subcommands/list subcommands/report
|
||||
TRIGGERS = triggers/cron-write triggers/post-delete triggers/post-deploy triggers/report
|
||||
BUILD = commands subcommands triggers
|
||||
PLUGIN_NAME = cron
|
||||
|
||||
include ../../common.mk
|
||||
194
plugins/cron/functions.go
Normal file
194
plugins/cron/functions.go
Normal file
@@ -0,0 +1,194 @@
|
||||
package cron
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
appjson "github.com/dokku/dokku/plugins/app-json"
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
|
||||
cronparser "github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
type templateCommand struct {
|
||||
ID string
|
||||
App string
|
||||
Command string
|
||||
Schedule string
|
||||
AltCommand string
|
||||
LogFile string
|
||||
}
|
||||
|
||||
func (t templateCommand) CronCommand() string {
|
||||
if t.AltCommand != "" {
|
||||
if t.LogFile != "" {
|
||||
return fmt.Sprintf("%s &>> %s", t.AltCommand, t.LogFile)
|
||||
}
|
||||
return t.AltCommand
|
||||
}
|
||||
|
||||
return fmt.Sprintf("dokku --rm run --cron-id %s %s", t.ID, t.App, t.Command)
|
||||
}
|
||||
|
||||
func fetchCronEntries(appName string) ([]templateCommand, error) {
|
||||
commands := []templateCommand{}
|
||||
scheduler := common.GetAppScheduler(appName)
|
||||
if scheduler != "docker-local" {
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
appjsonPath := appjson.GetAppjsonPath(appName)
|
||||
if !common.FileExists(appjsonPath) {
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(appjsonPath)
|
||||
if err != nil {
|
||||
return commands, fmt.Errorf("Cannot read app.json file for %s: %v", appName, err)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(string(b)) == "" {
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
var appJSON appjson.AppJSON
|
||||
if err = json.Unmarshal(b, &appJSON); err != nil {
|
||||
return commands, fmt.Errorf("Cannot parse app.json for %s: %v", appName, err)
|
||||
}
|
||||
|
||||
for _, c := range appJSON.Cron {
|
||||
parser := cronparser.NewParser(cronparser.Minute | cronparser.Hour | cronparser.Dom | cronparser.Month | cronparser.Dow | cronparser.Descriptor)
|
||||
_, err := parser.Parse(c.Schedule)
|
||||
if err != nil {
|
||||
return commands, err
|
||||
}
|
||||
|
||||
commands = append(commands, templateCommand{
|
||||
App: appName,
|
||||
Command: c.Command,
|
||||
Schedule: c.Schedule,
|
||||
ID: generateCommandID(appName, c),
|
||||
})
|
||||
}
|
||||
|
||||
return commands, nil
|
||||
}
|
||||
|
||||
func deleteCrontab() error {
|
||||
command := common.NewShellCmd("crontab -l -u dokku")
|
||||
command.ShowOutput = false
|
||||
if !command.Execute() {
|
||||
return nil
|
||||
}
|
||||
|
||||
command = common.NewShellCmd("crontab -r -u dokku")
|
||||
command.ShowOutput = false
|
||||
out, err := command.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to remove schedule file: %v", string(out))
|
||||
}
|
||||
|
||||
common.LogInfo1("Removed")
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeCronEntries() error {
|
||||
apps, _ := common.DokkuApps()
|
||||
commands := []templateCommand{}
|
||||
for _, appName := range apps {
|
||||
scheduler := common.GetAppScheduler(appName)
|
||||
if scheduler != "docker-local" {
|
||||
continue
|
||||
}
|
||||
|
||||
c, err := fetchCronEntries(appName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commands = append(commands, c...)
|
||||
}
|
||||
|
||||
b, _ := common.PlugnTriggerOutput("cron-entries", "docker-local")
|
||||
common.Log(fmt.Sprintf("output: %s", string(b)))
|
||||
for _, line := range strings.Split(strings.TrimSpace(string(b[:])), "\n") {
|
||||
if strings.TrimSpace(line) == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
parts := strings.Split(line, ";")
|
||||
if len(parts) != 2 && len(parts) != 3 {
|
||||
return fmt.Errorf("Invalid injected cron task: %v", line)
|
||||
}
|
||||
|
||||
id := base64.StdEncoding.EncodeToString([]byte(strings.Join(parts, ";;;")))
|
||||
command := templateCommand{
|
||||
ID: id,
|
||||
Schedule: parts[0],
|
||||
AltCommand: parts[1],
|
||||
}
|
||||
if len(parts) == 3 {
|
||||
command.LogFile = parts[2]
|
||||
}
|
||||
commands = append(commands, command)
|
||||
}
|
||||
|
||||
if len(commands) == 0 {
|
||||
return deleteCrontab()
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"Commands": commands,
|
||||
}
|
||||
|
||||
t, err := getCronTemplate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmpFile, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("dokku-%s-%s", common.MustGetEnv("DOKKU_PID"), "WriteCronEntries"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Cannot create temporary schedule file: %v", err)
|
||||
}
|
||||
|
||||
defer tmpFile.Close()
|
||||
defer os.Remove(tmpFile.Name())
|
||||
|
||||
if err := t.Execute(tmpFile, data); err != nil {
|
||||
return fmt.Errorf("Unable to template out schedule file: %v", err)
|
||||
}
|
||||
|
||||
command := common.NewShellCmd(fmt.Sprintf("crontab -u dokku %s", tmpFile.Name()))
|
||||
command.ShowOutput = false
|
||||
out, err := command.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to update schedule file: %v", out)
|
||||
}
|
||||
|
||||
common.LogInfo1("Updated schedule file")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getCronTemplate() (*template.Template, error) {
|
||||
t := template.New("cron")
|
||||
|
||||
templatePath := filepath.Join(common.MustGetEnv("PLUGIN_ENABLED_PATH"), "cron", "templates", "cron.tmpl")
|
||||
b, err := ioutil.ReadFile(templatePath)
|
||||
if err != nil {
|
||||
return t, fmt.Errorf("Cannot read template file: %v", err)
|
||||
}
|
||||
|
||||
s := strings.TrimSpace(string(b))
|
||||
return t.Parse(s)
|
||||
}
|
||||
|
||||
func generateCommandID(appName string, c appjson.CronCommand) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(appName + "===" + c.Command + "===" + c.Schedule))
|
||||
}
|
||||
15
plugins/cron/go.mod
Normal file
15
plugins/cron/go.mod
Normal file
@@ -0,0 +1,15 @@
|
||||
module github.com/dokku/dokku/plugins/cron
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/dokku/dokku/plugins/app-json v0.0.0-00010101000000-000000000000
|
||||
github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
)
|
||||
|
||||
replace github.com/dokku/dokku/plugins/app-json => ../app-json
|
||||
|
||||
replace github.com/dokku/dokku/plugins/common => ../common
|
||||
15
plugins/cron/go.sum
Normal file
15
plugins/cron/go.sum
Normal file
@@ -0,0 +1,15 @@
|
||||
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=
|
||||
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
|
||||
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4quafGxDT9LDasjGdlGkzLbfmmrlng3kA=
|
||||
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg=
|
||||
github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
4
plugins/cron/plugin.toml
Normal file
4
plugins/cron/plugin.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku core cron plugin"
|
||||
version = "0.23.2"
|
||||
[plugin.config]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user