Skip to content

Commit 9eff0c3

Browse files
authored
Ease modification of base image (#1479)
1 parent 518a9ec commit 9eff0c3

15 files changed

+116
-38
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ jobs:
5858
sudo chmod +x "${{ matrix.compose_path }}/docker-compose"
5959
6060
- name: Integration Test
61-
run: |
62-
echo "Testing initial install"
63-
./install.sh
64-
./_integration-test/run.sh
65-
echo "Testing in-place upgrade"
66-
# Also test plugin installation here
67-
echo "sentry-auth-oidc" >> sentry/requirements.txt
68-
./install.sh --minimize-downtime
69-
./_integration-test/run.sh
61+
run: ./integration-test.sh
7062

7163
- name: Inspect failure
7264
if: failure()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ data/
8080
sentry/sentry.conf.py
8181
sentry/config.yml
8282
sentry/*.bak
83+
sentry/enhance-image.sh
8384
sentry/requirements.txt
8485
relay/credentials.json
8586
relay/config.yml

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Testing
2+
3+
Validate changes to the setup by running the integration test:
4+
5+
```shell
6+
./integration-test.sh
7+
```

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ Official bootstrap for running your own [Sentry](https://sentry.io/) with [Docke
1212

1313
## Setup
1414

15+
### Installation
16+
17+
To get started with all the defaults, simply clone the repo and run `./install.sh` in your local check-out. Sentry uses Python 3 by default since December 4th, 2020 and Sentry 21.1.0 is the last version to support Python 2.
18+
19+
During the install, a prompt will ask if you want to create a user account. If you require that the install not be blocked by the prompt, run `./install.sh --skip-user-prompt`.
20+
21+
Thinking of not managing this yourself? Check out the [SaaS migration docs](https://docs.sentry.io/product/sentry-basics/migration/) or [contact us](https://sentry.io/from/self-hosted) for help.
22+
23+
Please visit [our documentation](https://develop.sentry.dev/self-hosted/) for everything else.
24+
1525
### Customize DotEnv (.env) file
1626

1727
Environment specific configurations can be done in the `.env.custom` file. It will be located in the root directory of the Sentry installation.
@@ -20,15 +30,13 @@ By default, there exists no `.env.custom` file. In this case, you can manually a
2030

2131
Please keep in mind to check the `.env` file for changes, when you perform an upgrade of Sentry, so that you can adjust your `.env.custom` accordingly, if required.
2232

23-
### Installation
33+
### Enhance Sentry image
2434

25-
To get started with all the defaults, simply clone the repo and run `./install.sh` in your local check-out. Sentry uses Python 3 by default since December 4th, 2020 and Sentry 21.1.0 is the last version to support Python 2.
35+
To install plugins and their dependencies or make other modifications to the Sentry base image,
36+
copy `sentry/enhance-image.example.sh` to `sentry/enhance-image.sh` and add necessary steps there.
37+
For example, you can use `apt-get` to install dependencies and use `pip` to install plugins.
2638

27-
During the install, a prompt will ask if you want to create a user account. If you require that the install not be blocked by the prompt, run `./install.sh --skip-user-prompt`.
28-
29-
Thinking of not managing this yourself? Check out the [SaaS migration docs](https://docs.sentry.io/product/sentry-basics/migration/) or [contact us](https://sentry.io/from/self-hosted) for help.
30-
31-
Please visit [our documentation](https://develop.sentry.dev/self-hosted/) for everything else.
39+
After making modifications to `sentry/enhance-image.sh`, run `./install.sh` again to apply them.
3240

3341
## Tips & Tricks
3442

@@ -40,7 +48,7 @@ Sentry comes with a cleanup cron job that prunes events older than `90 days` by
4048

4149
If you want to install a specific release of Sentry, use the tags/releases on this repo.
4250

43-
We continously push the Docker image for each commit made into [Sentry](https://github.com/getsentry/sentry), and other services such as [Snuba](https://github.com/getsentry/snuba) or [Symbolicator](https://github.com/getsentry/symbolicator) to [our Docker Hub](https://hub.docker.com/u/getsentry) and tag the latest version on master as `:nightly`. This is also usually what we have on sentry.io and what the install script uses. You can use a custom Sentry image, such as a modified version that you have built on your own, or simply a specific commit hash by setting the `SENTRY_IMAGE` environment variable to that image name before running `./install.sh`:
51+
We continuously push the Docker image for each commit made into [Sentry](https://github.com/getsentry/sentry), and other services such as [Snuba](https://github.com/getsentry/snuba) or [Symbolicator](https://github.com/getsentry/symbolicator) to [our Docker Hub](https://hub.docker.com/u/getsentry) and tag the latest version on master as `:nightly`. This is also usually what we have on sentry.io and what the install script uses. You can use a custom Sentry image, such as a modified version that you have built on your own, or simply a specific commit hash by setting the `SENTRY_IMAGE` environment variable to that image name before running `./install.sh`:
4452

4553
```shell
4654
SENTRY_IMAGE=getsentry/sentry:83b1380 ./install.sh
@@ -57,7 +65,3 @@ sudo SENTRY_IMAGE=us.gcr.io/sentryio/sentry:83b1380 ./install.sh
5765
```
5866

5967
Where you replace `83b1380` with the sha you want to use.
60-
61-
[build-status-image]: https://github.com/getsentry/self-hosted/workflows/test/badge.svg
62-
[build-status-url]: https://github.com/getsentry/self-hosted/actions?query=workflow%3Atest+branch%3Amaster+event%3Apush
63-
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
source "$(dirname $0)/../install/_lib.sh"
5+
6+
source ../install/dc-detect-version.sh
7+
8+
# Negated version of ensure-customizations-work.sh, make changes in sync
9+
echo "${_group}Ensure customizations not present"
10+
! $dcr --no-deps web bash -c "if [ ! -e /created-by-enhance-image ]; then exit 1; fi"
11+
! $dcr --no-deps --entrypoint=/etc/sentry/entrypoint.sh sentry-cleanup bash -c "if [ ! -e /created-by-enhance-image ]; then exit 1; fi"
12+
! $dcr --no-deps web python -c "import ldap"
13+
! $dcr --no-deps --entrypoint=/etc/sentry/entrypoint.sh sentry-cleanup python -c "import ldap"
14+
echo "${_endgroup}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
source "$(dirname $0)/../install/_lib.sh"
5+
6+
source ../install/dc-detect-version.sh
7+
8+
# Negated version of ensure-customizations-not-present.sh, make changes in sync
9+
echo "${_group}Ensure customizations work"
10+
$dcr --no-deps web bash -c "if [ ! -e /created-by-enhance-image ]; then exit 1; fi"
11+
$dcr --no-deps --entrypoint=/etc/sentry/entrypoint.sh sentry-cleanup bash -c "if [ ! -e /created-by-enhance-image ]; then exit 1; fi"
12+
$dcr --no-deps web python -c "import ldap"
13+
$dcr --no-deps --entrypoint=/etc/sentry/entrypoint.sh sentry-cleanup python -c "import ldap"
14+
echo "${_endgroup}"

docker-compose.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ x-healthcheck-defaults: &healthcheck_defaults
1616
start_period: 10s
1717
x-sentry-defaults: &sentry_defaults
1818
<<: *restart_policy
19-
image: "$SENTRY_IMAGE"
19+
image: sentry-self-hosted-local
20+
build:
21+
context: ./sentry
22+
args:
23+
- SENTRY_IMAGE
2024
depends_on:
2125
redis:
2226
<<: *depends_on-healthy
@@ -321,7 +325,7 @@ services:
321325
build:
322326
context: ./cron
323327
args:
324-
BASE_IMAGE: "$SENTRY_IMAGE"
328+
BASE_IMAGE: sentry-self-hosted-local
325329
entrypoint: "/entrypoint.sh"
326330
command: '"0 0 * * * gosu sentry sentry cleanup --days $SENTRY_EVENT_RETENTION_DAYS"'
327331
nginx:

install/build-docker-images.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
echo "${_group}Building and tagging Docker images ..."
22

33
echo ""
4+
# Build any service that provides the image sentry-self-hosted-local first,
5+
# as it is used as the base image for sentry-cleanup-self-hosted-local.
6+
$dc build --force-rm web
47
$dc build --force-rm
58
echo ""
69
echo "Docker images built."
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
echo "${_group}Ensuring files from examples ..."
22

3-
ensure_file_from_example $SENTRY_CONFIG_PY
4-
ensure_file_from_example $SENTRY_CONFIG_YML
3+
ensure_file_from_example "$SENTRY_CONFIG_PY"
4+
ensure_file_from_example "$SENTRY_CONFIG_YML"
55
ensure_file_from_example '../symbolicator/config.yml'
6-
ensure_file_from_example '../sentry/requirements.txt'
76

87
echo "${_endgroup}"

integration-test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
echo "Reset customizations"
5+
rm -f sentry/enhance-image.sh
6+
rm -f sentry/requirements.txt
7+
8+
echo "Testing initial install"
9+
./install.sh
10+
./_integration-test/run.sh
11+
./_integration-test/ensure-customizations-not-present.sh
12+
13+
echo "Make customizations"
14+
cat <<EOT > sentry/enhance-image.sh
15+
#!/bin/bash
16+
touch /created-by-enhance-image
17+
apt-get update
18+
apt-get install -y gcc libsasl2-dev python-dev libldap2-dev libssl-dev
19+
EOT
20+
chmod +x sentry/enhance-image.sh
21+
printf "python-ldap" > sentry/requirements.txt
22+
23+
echo "Testing in-place upgrade and customizations"
24+
./install.sh --minimize-downtime
25+
./_integration-test/run.sh
26+
./_integration-test/ensure-customizations-work.sh

0 commit comments

Comments
 (0)