Stacksmith merger (#18)
* switch to harpoon installer * removed unused `installer.run.sha256` * bump java version to 1.8.0_71-0 * added sha256 hash for package verification * switch to `gcr.io/stacksmith-images/ubuntu:14.04` base image * removed unused files * tests: updated for current feature set * switch to `gcr.io/stacksmith-images/ubuntu:14.04-r05` base image * organize dockerfile for stacksmith (#2) * verify checksum in harpoon commands * removed `BITNAMI_APP_DIR` macro * removed `BITNAMI_APP_VOL_PREFIX` macro * moved hacks to `app-entrypoint.sh` * organize dockerfile for stacksmith * added `VOLUME` instruction * tests: volume tests * tests: remove host volumes in cleanup * app-entrypoint: remove mkdir instrcution * tests: restored test to deploy sample application * upgrade to `tomcat-8.0.35-0` * readme: updates * updated `.dockerignore` rules * tests: bump `SLEEP_TIME` * readme: fixes
This commit is contained in:
parent
3661a3061d
commit
150c58758f
|
|
@ -1,2 +1,3 @@
|
|||
.git
|
||||
.git/
|
||||
tests/
|
||||
README.md
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
*.run
|
||||
*.tar.gz
|
||||
|
|
|
|||
|
|
@ -1,20 +1,22 @@
|
|||
FROM bitnami/base-ubuntu:14.04-onbuild
|
||||
FROM gcr.io/stacksmith-images/ubuntu:14.04-r07
|
||||
MAINTAINER Bitnami <containers@bitnami.com>
|
||||
|
||||
ENV BITNAMI_APP_DIR=$BITNAMI_PREFIX/apache-tomcat \
|
||||
ENV BITNAMI_IMAGE_VERSION=8.0.35-r0 \
|
||||
BITNAMI_APP_NAME=tomcat \
|
||||
BITNAMI_APP_USER=tomcat \
|
||||
BITNAMI_APP_DAEMON=catalina.sh \
|
||||
BITNAMI_APP_VERSION=7.0.68-0
|
||||
BITNAMI_APP_USER=tomcat
|
||||
|
||||
ENV BITNAMI_APP_VOL_PREFIX=/bitnami/$BITNAMI_APP_NAME \
|
||||
PATH=$BITNAMI_APP_DIR/bin:$PATH
|
||||
RUN bitnami-pkg install java-1.8.0_91-0 --checksum 64cf20b77dc7cce3a28e9fe1daa149785c9c8c13ad1249071bc778fa40ae8773
|
||||
ENV PATH=/opt/bitnami/java/bin:$PATH
|
||||
|
||||
RUN $BITNAMI_PREFIX/install.sh --tomcat_manager_username manager
|
||||
RUN bitnami-pkg unpack tomcat-8.0.35-0 --checksum d86af6bade1325215d4dd1b63aefbd4a57abb05a71672e5f58e27ff2fd49325b
|
||||
RUN ln -sf /opt/bitnami/$BITNAMI_APP_NAME/data /app
|
||||
|
||||
ENV PATH=/opt/bitnami/$BITNAMI_APP_NAME/bin:$PATH
|
||||
|
||||
COPY rootfs/ /
|
||||
ENTRYPOINT ["/app-entrypoint.sh"]
|
||||
CMD ["harpoon", "start", "--foreground", "tomcat"]
|
||||
|
||||
VOLUME ["/bitnami/$BITNAMI_APP_NAME"]
|
||||
|
||||
EXPOSE 8080
|
||||
VOLUME ["$BITNAMI_APP_VOL_PREFIX/conf", "$BITNAMI_APP_VOL_PREFIX/logs"]
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
# TLDR
|
||||
|
||||
```bash
|
||||
docker run --name tomcat bitnami/tomcat
|
||||
docker run --name tomcat bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
## Docker Compose
|
||||
|
||||
```
|
||||
```yaml
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
image: bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
# Get this image
|
||||
|
|
@ -34,31 +34,45 @@ docker pull bitnami/tomcat:[TAG]
|
|||
If you wish, you can also build the image yourself.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/bitnami/bitnami-docker-tomcat.git
|
||||
cd bitnami-docker-tomcat
|
||||
docker build -t bitnami/tomcat .
|
||||
docker build -t bitnami/tomcat:latest https://github.com/bitnami/bitnami-docker-tomcat.git
|
||||
```
|
||||
|
||||
# Deploying web applications on Tomcat
|
||||
# Persisting your Tomcat configurations and deployments
|
||||
|
||||
This Tomcat image exposes a volume at `/app`. This path acts as the Tomcat webapps directory. At this location, you either copy a so-called *exploded web application*, i.e. non-compressed, or a compressed web application resource (`.WAR`) file and it will automatically be deployed by Tomcat at startup.
|
||||
If you remove the container all your Tomcat configurations and deployments will be lost. To avoid this you should mount a volume that will persist even after the container is removed.
|
||||
|
||||
**Note!**
|
||||
You can also deploy web applications on a running Tomcat instance.
|
||||
If you have already started using your Tomcat deployment, follow the steps on
|
||||
[backing up](#backing-up-your-container) and [restoring](#restoring-a-backup) to pull the data from your running container down to your host.
|
||||
|
||||
The image exposes a volume at `/bitnami/tomcat` for the Tomcat configurations and application deployments. For persistence you can mount a directory at this location from your host. If the mounted directory is empty, it will be initialized on the first run.
|
||||
|
||||
```bash
|
||||
docker run -v /path/to/app:/app bitnami/tomcat
|
||||
docker run -v /path/to/tomcat-persistence:/bitnami/tomcat bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```
|
||||
```yaml
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
image: bitnami/tomcat:latest
|
||||
volumes:
|
||||
- /path/to/app:/app
|
||||
- /path/to/tomcat-persistence:/bitnami/tomcat
|
||||
```
|
||||
|
||||
# Deploying web applications on Tomcat
|
||||
|
||||
The `/bitnami/tomcat/data` directory is configured as the Tomcat webapps deployment directory. At this location, you either copy a so-called *exploded web application*, i.e. non-compressed, or a compressed web application resource (`.WAR`) file and it will automatically be deployed by Tomcat.
|
||||
|
||||
Additionally a helper symlink `/app` is present that points to the webapps deployment directory which enables us to deploy applications on a running Tomcat instance by simply doing:
|
||||
|
||||
```bash
|
||||
docker cp /path/to/app.war tomcat:/app
|
||||
```
|
||||
|
||||
**Note!**
|
||||
You can also deploy web applications on a running Tomcat instance using the Tomcat management interface.
|
||||
|
||||
**Further Reading:**
|
||||
|
||||
- [Tomcat Web Application Deployment](https://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html)
|
||||
|
|
@ -68,7 +82,7 @@ tomcat:
|
|||
To access your web server from your host machine you can ask Docker to map a random port on your host to port `8080` exposed in the container.
|
||||
|
||||
```bash
|
||||
docker run --name tomcat -P bitnami/tomcat
|
||||
docker run --name tomcat -P bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
Run `docker port` to determine the random ports Docker assigned.
|
||||
|
|
@ -81,55 +95,69 @@ $ docker port tomcat
|
|||
You can also manually specify the ports you want forwarded from your host to the container.
|
||||
|
||||
```bash
|
||||
docker run -p 8080:8080 bitnami/tomcat
|
||||
docker run -p 8080:8080 bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
Access your web server in the browser by navigating to [http://localhost:8080](http://localhost:8080/).
|
||||
|
||||
# Configuration
|
||||
|
||||
## Setting the `manager` password on first run
|
||||
## Creating a custom user
|
||||
|
||||
By default, the `manager` user is not assigned a password. To secure your Tomcat server you should assign a password to this user. Passing the `TOMCAT_PASSWORD` environment variable when running the image for the first time will set the password of the `manager` user to the value of `TOMCAT_PASSWORD`.
|
||||
By default, a management user named `user` is created and is not assigned a password. Passing the `TOMCAT_PASSWORD` environment variable when running the image for the first time will set the password of this user to the value of `TOMCAT_PASSWORD`.
|
||||
|
||||
Additionally you can specify a user name for the management user using the `TOMCAT_USER` environment variable. When not specified, the `TOMCAT_PASSWORD` configuration is applied on the default user (`user`).
|
||||
|
||||
```bash
|
||||
docker run --name tomcat -e TOMCAT_PASSWORD=password123 bitnami/tomcat
|
||||
docker run --name tomcat \
|
||||
-e TOMCAT_USER=my_user \
|
||||
-e TOMCAT_PASSWORD=my_password \
|
||||
bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```
|
||||
```yaml
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
image: bitnami/tomcat:latest
|
||||
environment:
|
||||
- TOMCAT_PASSWORD=password123
|
||||
- TOMCAT_USER=my_user
|
||||
- TOMCAT_PASSWORD=my_password
|
||||
```
|
||||
|
||||
## Configuration files
|
||||
|
||||
This image looks for Tomcat configuration files in `/bitnami/tomcat/conf`. You can mount a volume at this location with your own configuration, or the default configuration will be copied to your volume if it is empty.
|
||||
This image looks for Tomcat configuration files in `/bitnami/tomcat/conf`. You may recall from the [persisting your tomcat configurations and deployments](#persisting-your-tomcat-configurations-and-deployments) section, `/bitnami/tomcat` is the path to the persistence volume.
|
||||
|
||||
Create a directory named `conf/` at this location with your own configuration, or the default configuration will be copied on the first run which can be customized later.
|
||||
|
||||
### Step 1: Run the Tomcat image
|
||||
|
||||
Run the Tomcat image, mounting a directory from your host.
|
||||
|
||||
```bash
|
||||
docker run --name tomcat -v /path/to/tomcat/conf:/bitnami/tomcat/conf bitnami/tomcat
|
||||
docker run --name tomcat -v /path/to/tomcat-persistence:/bitnami/tomcat bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```
|
||||
```yaml
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
image: bitnami/tomcat:latest
|
||||
volumes:
|
||||
- /path/to/tomcat/conf:/bitnami/tomcat/conf
|
||||
- /path/to/tomcat-persistence:/bitnami/tomcat
|
||||
```
|
||||
|
||||
### Step 2: Edit the configuration
|
||||
|
||||
Edit the configuration on your host using your favorite editor.
|
||||
|
||||
eg.
|
||||
|
||||
```bash
|
||||
vim /path/to/tomcat-persistence/conf/server.xml
|
||||
```
|
||||
|
||||
### Step 3: Restart Tomcat
|
||||
|
||||
After changing the configuration, restart your Tomcat container for the changes to take effect.
|
||||
|
|
@ -150,11 +178,7 @@ docker-compose restart tomcat
|
|||
|
||||
# Logging
|
||||
|
||||
The Bitnami Tomcat Docker Image supports two different logging modes: logging to stdout, and logging to a file.
|
||||
|
||||
## Logging to stdout
|
||||
|
||||
The default behavior is to log to stdout, as Docker expects. These will be collected by Docker, converted to JSON and stored in the host, to be accessible via the `docker logs` command.
|
||||
The Bitnami Tomcat Docker image sends the container logs to the `stdout`. To view the logs:
|
||||
|
||||
```bash
|
||||
docker logs tomcat
|
||||
|
|
@ -166,26 +190,7 @@ or using Docker Compose:
|
|||
docker-compose logs tomcat
|
||||
```
|
||||
|
||||
This method of logging has the downside of not being easy to manage. Without an easy way to rotate logs, they could grow exponentially and take up large amounts of disk space on your host.
|
||||
|
||||
## Logging to file
|
||||
|
||||
To log to file, run the Tomcat image, mounting a directory from your host at `/bitnami/tomcat/logs`. This will instruct the container to send logs to your directory.
|
||||
|
||||
```bash
|
||||
docker run --name tomcat -v /path/to/tomcat/logs:/bitnami/tomcat/logs bitnami/tomcat
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
volumes:
|
||||
- /path/to/tomcat/logs:/bitnami/tomcat/logs
|
||||
```
|
||||
|
||||
To perform operations (e.g. logrotate) on the logs, mount the same directory in a container designed to operate on log files, such as logstash.
|
||||
You can configure the containers [logging driver](https://docs.docker.com/engine/admin/logging/overview/) using the `--log-driver` option if you wish to consume the container logs differently. In the default configuration docker uses the `json-file` driver.
|
||||
|
||||
# Maintenance
|
||||
|
||||
|
|
@ -210,38 +215,32 @@ docker-compose stop tomcat
|
|||
We need to mount two volumes in a container we will use to create the backup: a directory on your host to store the backup in, and the volumes from the container we just stopped so we can access the data.
|
||||
|
||||
```bash
|
||||
docker run --rm -v /path/to/backups:/backups --volumes-from tomcat busybox \
|
||||
docker run --rm -v /path/to/tomcat-backups:/backups --volumes-from tomcat busybox \
|
||||
cp -a /bitnami/tomcat /backups/latest
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```bash
|
||||
docker run --rm -v /path/to/backups:/backups --volumes-from `docker-compose ps -q tomcat` busybox \
|
||||
docker run --rm -v /path/to/tomcat-backups:/backups --volumes-from `docker-compose ps -q tomcat` busybox \
|
||||
cp -a /bitnami/tomcat /backups/latest
|
||||
```
|
||||
|
||||
**Note!**
|
||||
If you only need to backup configuration, you can change the first argument to `cp` to `/bitnami/tomcat/conf`.
|
||||
|
||||
## Restoring a backup
|
||||
|
||||
Restoring a backup is as simple as mounting the backup as volumes in the container.
|
||||
|
||||
```bash
|
||||
docker run -v /path/to/backups/latest/conf:/bitnami/tomcat/conf \
|
||||
-v /path/to/backups/latest/logs:/bitnami/tomcat/logs \
|
||||
bitnami/tomcat
|
||||
docker run -v /path/to/tomcat-backups/latest:/bitnami/tomcat bitnami/tomcat:latest
|
||||
```
|
||||
|
||||
or using Docker Compose:
|
||||
|
||||
```
|
||||
```yaml
|
||||
tomcat:
|
||||
image: bitnami/tomcat
|
||||
image: bitnami/tomcat:latest
|
||||
volumes:
|
||||
- /path/to/backups/latest/conf:/bitnami/tomcat/conf
|
||||
- /path/to/backups/latest/logs:/bitnami/tomcat/logs
|
||||
- /path/to/tomcat-backups/latest:/bitnami/tomcat
|
||||
```
|
||||
|
||||
## Upgrade this image
|
||||
|
|
@ -277,8 +276,7 @@ docker-compose rm -v tomcat
|
|||
|
||||
### Step 4: Run the new image
|
||||
|
||||
Re-create your container from the new image, [restoring your backup](#restoring-a-backup) if
|
||||
necessary.
|
||||
Re-create your container from the new image, [restoring your backup](#restoring-a-backup) if necessary.
|
||||
|
||||
```bash
|
||||
docker run --name tomcat bitnami/tomcat:latest
|
||||
|
|
@ -298,6 +296,13 @@ This image is tested for expected runtime behavior, using the [Bats](https://git
|
|||
bats test.sh
|
||||
```
|
||||
|
||||
# Notable Changes
|
||||
|
||||
## 8.0.35-r0
|
||||
|
||||
- All volumes have been merged at `/bitnami/tomcat`. Now you only need to mount a single volume at `/bitnami/tomcat` for persistence.
|
||||
- The logs are always sent to the `stdout` and are no longer collected in the volume.
|
||||
|
||||
# Contributing
|
||||
|
||||
We'd love for you to contribute to this container. You can request new features by creating an [issue](https://github.com/bitnami/bitnami-docker-tomcat/issues), or submit a [pull request](https://github.com/bitnami/bitnami-docker-tomcat/pulls) with your contribution.
|
||||
|
|
@ -310,8 +315,7 @@ If you encountered a problem running this container, you can file an [issue](htt
|
|||
- Docker version (`docker version`)
|
||||
- Output of `docker info`
|
||||
- Version of this container (`echo $BITNAMI_APP_VERSION` inside the container)
|
||||
- The command you used to run the container, and any relevant output you saw (masking any sensitive
|
||||
information)
|
||||
- The command you used to run the container, and any relevant output you saw (masking any sensitive information)
|
||||
|
||||
# License
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
$BITNAMI_APP_NAME cheatsheet:
|
||||
|
||||
ENVIRONMENT VARIABLES:
|
||||
TOMCAT_PASSWORD: Password set for the manager user at first boot of your $BITNAMI_APP_NAME server (default: none).
|
||||
|
||||
VOLUMES:
|
||||
/app: Location of your $BITNAMI_APP_NAME webapps.
|
||||
$BITNAMI_APP_VOL_PREFIX/conf: Location of $BITNAMI_APP_NAME config files.
|
||||
$BITNAMI_APP_VOL_PREFIX/logs: Location of $BITNAMI_APP_NAME logs.
|
||||
|
||||
PORTS:
|
||||
8080: Default $BITNAMI_APP_NAME port.
|
||||
|
||||
MISC:
|
||||
Options: You can add extra options during the docker run using the -- prefix.
|
||||
Note: The password is only set the first time you run the container.
|
||||
|
||||
COMMANDS:
|
||||
print-help: Print this page.
|
||||
check-updates: Check if a new version of the $BITNAMI_APP_NAME image is available.
|
||||
|
||||
Visit $GITHUB_PAGE for more information.
|
||||
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
environment_variables:
|
||||
TOMCAT_PASSWORD: "Password set for the manager user at first boot of your $BITNAMI_APP_NAME server (default: none)."
|
||||
volumes:
|
||||
/app: "Location of your $BITNAMI_APP_NAME webapps."
|
||||
$BITNAMI_APP_VOL_PREFIX/conf: "Location of $BITNAMI_APP_NAME config files."
|
||||
$BITNAMI_APP_VOL_PREFIX/logs: "Location of $BITNAMI_APP_NAME logs."
|
||||
ports:
|
||||
8080: "Default $BITNAMI_APP_NAME port."
|
||||
misc:
|
||||
Options: "You can add extra options during the docker run using the -- prefix."
|
||||
Note: "The password is only set the first time you run the container."
|
||||
|
|
@ -1 +0,0 @@
|
|||
684b0515479de3ee064761374396d0dd012435be90dd21332b9a2b87f09a76d8 /tmp/installer.run
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd $BITNAMI_APP_DIR
|
||||
|
||||
# move the default conf directory
|
||||
mv conf conf.defaults
|
||||
|
||||
# move the default webapps directory
|
||||
mv webapps webapps.defaults
|
||||
|
||||
# Create an empty webapps directory
|
||||
mkdir webapps
|
||||
|
||||
# symlink mount points at root to install dir
|
||||
ln -s $BITNAMI_APP_DIR/webapps /app
|
||||
ln -s $BITNAMI_APP_DIR/conf $BITNAMI_APP_VOL_PREFIX/conf
|
||||
ln -s $BITNAMI_APP_DIR/logs $BITNAMI_APP_VOL_PREFIX/logs
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [[ "$1" == "harpoon" && "$2" == "start" ]]; then
|
||||
status=`harpoon inspect $BITNAMI_APP_NAME`
|
||||
if [[ "$status" == *'"lifecycle": "unpacked"'* ]]; then
|
||||
harpoon initialize $BITNAMI_APP_NAME \
|
||||
${TOMCAT_USER:+--username $TOMCAT_USER} \
|
||||
${TOMCAT_PASSWORD:+--password $TOMCAT_PASSWORD}
|
||||
fi
|
||||
chown $BITNAMI_APP_USER: /bitnami/$BITNAMI_APP_NAME || true
|
||||
fi
|
||||
|
||||
exec /entrypoint.sh "$@"
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
# Tomcat Utility functions
|
||||
|
||||
initialize_webapps_directory() {
|
||||
echo "==> Initializing webapps directory..."
|
||||
echo ""
|
||||
cp -a $BITNAMI_APP_DIR/webapps.defaults/* /app/
|
||||
touch /app/.initialized
|
||||
}
|
||||
|
||||
set_manager_password() {
|
||||
if [ "$TOMCAT_PASSWORD" ]; then
|
||||
echo ""
|
||||
echo "==> Setting manager password..."
|
||||
sed -i "s/^\(<user username=\"manager\" password=\"\)\([^ \"]*\)\(\".*\)/\1$TOMCAT_PASSWORD\3/" $BITNAMI_APP_VOL_PREFIX/conf/tomcat-users.xml
|
||||
fi
|
||||
}
|
||||
|
||||
print_tomcat_password() {
|
||||
if [ -z $TOMCAT_PASSWORD ]; then
|
||||
echo "**none**"
|
||||
else
|
||||
echo $TOMCAT_PASSWORD
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
if [ ! "$(ls -A $BITNAMI_APP_VOL_PREFIX/conf)" ]; then
|
||||
generate_conf_files
|
||||
|
||||
set_manager_password
|
||||
|
||||
print_app_credentials $BITNAMI_APP_NAME manager `print_tomcat_password`
|
||||
else
|
||||
print_container_already_initialized $BITNAMI_APP_NAME
|
||||
fi
|
||||
|
||||
if [ ! -f /app/.initialized ]; then
|
||||
initialize_webapps_directory
|
||||
fi
|
||||
|
||||
chown -R $BITNAMI_APP_USER:$BITNAMI_APP_USER $BITNAMI_APP_VOL_PREFIX/conf/ $BITNAMI_APP_VOL_PREFIX/logs/ /app/ || true
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
failcount=0
|
||||
if [ -f $BITNAMI_APP_DIR/tmp/failcount ]; then
|
||||
failcount=$(cat $BITNAMI_APP_DIR/tmp/failcount)
|
||||
fi
|
||||
|
||||
start=$(cat $BITNAMI_APP_DIR/tmp/start)
|
||||
stop=`date '+%d%H%M%S'`
|
||||
interval=`expr $stop - $start`
|
||||
if test $interval -lt 30 ; then
|
||||
failcount=`expr $failcount + 1`
|
||||
else
|
||||
failcount=0
|
||||
fi
|
||||
echo -n $failcount > $BITNAMI_APP_DIR/tmp/failcount
|
||||
|
||||
# bring down container on frequent failures. something is definitely wrong
|
||||
if test $failcount -ge 3 ; then
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
fi
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
set -e
|
||||
source $BITNAMI_PREFIX/bitnami-utils.sh
|
||||
|
||||
mkdir -p $BITNAMI_APP_DIR/tmp
|
||||
date '+%d%H%M%S' > $BITNAMI_APP_DIR/tmp/start
|
||||
exec s6-setuidgid $BITNAMI_APP_USER $BITNAMI_APP_DAEMON run ${EXTRA_OPTIONS:+"$EXTRA_OPTIONS"}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
TOMCAT_USER=manager
|
||||
TOMCAT_DEFAULT_USER=user
|
||||
TOMCAT_USER=tomcat_user
|
||||
TOMCAT_PASSWORD=test_password
|
||||
|
||||
# source the helper script
|
||||
APP_NAME=tomcat
|
||||
SLEEP_TIME=10
|
||||
SLEEP_TIME=30
|
||||
VOL_PREFIX=/bitnami/$APP_NAME
|
||||
VOLUMES=/app:$VOL_PREFIX/conf:$VOL_PREFIX/logs
|
||||
VOLUMES=$VOL_PREFIX
|
||||
load tests/docker_helper
|
||||
|
||||
# Cleans up all running/stopped containers and host mounted volumes
|
||||
|
|
@ -29,108 +30,79 @@ cleanup_environment
|
|||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "Manager has access to management area" {
|
||||
@test "Default user is created without a password" {
|
||||
container_create default -d
|
||||
run curl_client default -i http://$TOMCAT_USER@$APP_NAME:8080/manager/html
|
||||
run curl_client default -i http://$TOMCAT_DEFAULT_USER@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "User manager created with password" {
|
||||
@test "Can assign custom password for the default user" {
|
||||
container_create default -d \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
run curl_client default -i http://$TOMCAT_DEFAULT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "Can create custom user with manager role" {
|
||||
container_create default -d \
|
||||
-e TOMCAT_USER=$TOMCAT_USER \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "Can't access management area without password" {
|
||||
container_create default -d \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
|
||||
run curl_client default -i http://$TOMCAT_USER@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '401 Unauthorized' ]]
|
||||
}
|
||||
|
||||
@test "Password is preserved after restart" {
|
||||
@test "Password and settings are preserved after restart" {
|
||||
container_create default -d \
|
||||
-e TOMCAT_USER=$TOMCAT_USER \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
|
||||
container_restart default
|
||||
|
||||
run container_logs default
|
||||
[[ "$output" =~ "The credentials were set on first boot." ]]
|
||||
|
||||
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "All the volumes exposed" {
|
||||
container_create default -d
|
||||
|
||||
run container_inspect default --format {{.Mounts}}
|
||||
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX" ]]
|
||||
}
|
||||
|
||||
@test "Data gets generated in conf and app if bind mounted in the host" {
|
||||
@test "Data gets generated in volume if bind mounted in the host" {
|
||||
container_create_with_host_volumes default -d \
|
||||
-e TOMCAT_USER=$TOMCAT_USER \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
|
||||
# files expected in conf volume (subset)
|
||||
run container_exec default ls -la $VOL_PREFIX/conf/
|
||||
[[ "$output" =~ "server.xml" ]]
|
||||
[[ "$output" =~ "tomcat-users.xml" ]]
|
||||
|
||||
# files expected in app volume (subset)
|
||||
run container_exec default ls -la /app/
|
||||
run container_exec default ls -la $VOL_PREFIX/data/
|
||||
[[ "$output" =~ "ROOT" ]]
|
||||
[[ "$output" =~ "manager" ]]
|
||||
[[ "$output" =~ "host-manager" ]]
|
||||
}
|
||||
|
||||
@test "If host mounted, password and settings are preserved after deletion" {
|
||||
container_create_with_host_volumes default -d \
|
||||
-e TOMCAT_USER=$TOMCAT_USER \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
|
||||
# remove container
|
||||
container_remove default
|
||||
|
||||
# recreate container without specifying any environment variables
|
||||
container_create_with_host_volumes default -d
|
||||
|
||||
run curl_client default -i http://$TOMCAT_USER:$TOMCAT_PASSWORD@$APP_NAME:8080/manager/html
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
||||
@test "Configuration changes are preserved after deletion" {
|
||||
container_create_with_host_volumes default -d
|
||||
|
||||
# modify catalina.properties
|
||||
container_exec default sed -i 's|^[#]*[ ]*tomcat.util.buf.StringCache.byte.enabled[ ]*=.*|tomcat.util.buf.StringCache.byte.enabled=false|' $VOL_PREFIX/conf/catalina.properties
|
||||
container_exec default sed -i 's|^[#]*[ ]*tomcat.util.buf.StringCache.char.enabled[ ]*=.*|tomcat.util.buf.StringCache.char.enabled=false|' $VOL_PREFIX/conf/catalina.properties
|
||||
container_exec default sed -i 's|^[#]*[ ]*tomcat.util.buf.StringCache.cacheSize[ ]*=.*|tomcat.util.buf.StringCache.cacheSize=4096|' $VOL_PREFIX/conf/catalina.properties
|
||||
|
||||
# stop and remove container
|
||||
container_remove default
|
||||
|
||||
# relaunch container with host volumes
|
||||
container_create_with_host_volumes default -d
|
||||
|
||||
run container_exec default cat $VOL_PREFIX/conf/catalina.properties
|
||||
[[ "$output" =~ "tomcat.util.buf.StringCache.byte.enabled=false" ]]
|
||||
[[ "$output" =~ "tomcat.util.buf.StringCache.char.enabled=false" ]]
|
||||
[[ "$output" =~ "tomcat.util.buf.StringCache.cacheSize=4096" ]]
|
||||
}
|
||||
|
||||
@test "Deploy sample application" {
|
||||
container_create_with_host_volumes default -d \
|
||||
-e TOMCAT_USER=$TOMCAT_USER \
|
||||
-e TOMCAT_PASSWORD=$TOMCAT_PASSWORD
|
||||
|
||||
# download sample app into the app deployment directory, allow 10 secs for the autodeploy to happen
|
||||
container_exec default curl --noproxy localhost --retry 5 http://localhost:8080/docs/appdev/sample/sample.war -o /app/sample.war
|
||||
container_exec default curl --noproxy localhost --retry 5 \
|
||||
http://localhost:8080/docs/appdev/sample/sample.war -o $VOL_PREFIX/data/sample.war
|
||||
sleep 10
|
||||
|
||||
# test app deployment
|
||||
run curl_client default -i http://$APP_NAME:8080/sample/hello.jsp
|
||||
[[ "$output" =~ '200 OK' ]]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue