Skip to content

Commit

Permalink
Merge branch 'develop-sling12' into issues/618-htl-server
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrockwell authored Apr 24, 2021
2 parents 6088a74 + 91a1a8e commit 5901bee
Show file tree
Hide file tree
Showing 22 changed files with 206 additions and 407 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ before_script:
script:
- if [ ${TRAVIS_PULL_REQUEST} != "false" ]; then BUILD_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH; else BUILD_BRANCH=$TRAVIS_BRANCH; fi
- ./travis-build.sh
- cd docker && ./builddocker.sh
- cd docker && ./builddocker.sh && ./builddocker-remote-replication.sh
- ./pushdocker-travis.sh

after_script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,10 @@ private void updateResourceTree(Resource resource, Map<String, Object> propertie

for (Entry<String, Object> entry : properties.entrySet()) {
String name = entry.getKey();
if (!isPropertyCopyable(name)) {
continue;
}

Object value = entry.getValue();
if (value instanceof Map) {
applyChildProperties(resource, name, (Map) value);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -532,15 +532,11 @@ export default {
activeTab : function(tab) {
if (tab === 'versions'){
this.showVersions()
} else if (tab === 'references'){
this.showReferencedBy()
}
},
currentObject : function(path) {
if (this.activeTab === 'versions'){
if (this.activeTab === 'versions') {
this.showVersions()
} else if (this.activeTab === 'references'){
this.showReferencedBy()
}
if (this.stateToolsEdit) {
this.onEdit()
Expand Down Expand Up @@ -782,14 +778,6 @@ export default {
showVersions() {
$perAdminApp.getApi().populateVersions(this.currentObject);
},
showReferencedBy() {
this.loading = true
$perAdminApp.getApi()
.populateReferencedBy(this.currentObject)
.then(() => {
this.loading = false
})
},
deleteVersion(me, target) {
$perAdminApp.stateAction('deleteVersion', { path: target.path, version: target.version.name });
},
Expand Down
17 changes: 11 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FROM adoptopenjdk/openjdk11:latest

ENV APP_VERSION 2.0.0

WORKDIR /app

RUN apt update -q \
Expand All @@ -15,8 +13,6 @@ RUN apt update -q \

ENV PATH "/usr/local/lib/nodejs/node-v10.16.0-linux-x64/bin:$PATH"

COPY files/* /app/binaries/
COPY scripts/*.sh /app/scripts/

# Start - Use repository/package pinning to upgrade libvips from version 8.4 to 8.6
COPY overlay/etc/apt/preferences.d/* /etc/apt/preferences.d/
Expand All @@ -26,6 +22,8 @@ RUN echo "deb http://archive.ubuntu.com/ubuntu/ focal main restricted" >> /etc/a
&& apt --only-upgrade install -y libvips libvips-tools
# End

COPY files/node-v10.16.0-linux-x64.tar.xz /app/binaries/node-v10.16.0-linux-x64.tar.xz

RUN mkdir -p /usr/local/lib/nodejs \
&& tar -xf /app/binaries/node-v10.16.0-linux-x64.tar.xz -C /usr/local/lib/nodejs \
&& echo $PATH \
Expand All @@ -34,10 +32,17 @@ RUN mkdir -p /usr/local/lib/nodejs \
&& echo npx: $(npx -v) \
&& apt-get purge -y --auto-remove && rm -rf /var/lib/apt/lists/* && rm -rf /etc/apt/sources.list.d/temp.list;

ARG runmode=none
ENV APP_VERSION 2.0.0
ENV RUNMODE=${runmode}

COPY files/* /app/binaries/
COPY scripts/*.sh /app/scripts/

RUN scripts/install-sling.sh
RUN scripts/install-peregrine.sh
RUN scripts/install-peregrine.sh ${RUNMODE}

ENTRYPOINT /app/scripts/start.sh && tail -qF /app/sling/logs/error.log
ENTRYPOINT /app/scripts/start.sh ${RUNMODE} && tail -qF /app/sling/logs/error.log

#HEALTHCHECK --interval=15s --retries=20 \
# CMD /app/healthcheck.sh
Expand Down
19 changes: 15 additions & 4 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,38 @@ A prebuilt Peregrine Docker image is available on [Docker Hub](https://hub.docke

# Running Peregrine in Docker

1. Pull down the Docker image.
1. Pull down the Docker images.

$ docker pull peregrinecms/peregrine-cms:latest
$ docker pull peregrinecms/peregrine-cms:latest-author
$ docker pull peregrinecms/peregrine-cms:latest-publish

2. Run the container.

$ docker run -it -p 8080:8080 peregrinecms/peregrine-cms:latest
$ docker run -it -p 8080:8080 peregrinecms/peregrine-cms:latest

3. Open a browser and visit http://localhost:8080. Login with `admin` / ` admin`.

3. Open a browser and visit http://localhost:8080 and login with `admin` / ` admin`.


# Building the Image

If you prefer to build the Peregrine image yourself, simply run:

$ ./travis-build.sh
$ cd docker
$ ./builddocker.sh
$ ./builddocker.sh #local
$ ./builddocker-remote-replication.sh #author and publish

Launch the locally built docker image

$ docker run -it -p 8080:8080 peregrinecms/peregrine-cms:latest

or for the remote (author/publish) use-case

$ docker run -d --rm -p 8080:8080 --name peregrine-author peregrinecms/peregrine-cms:latest-author
$ docker run -d --rm -p 8180:8080 --name peregrine-publish peregrinecms/peregrine-cms:latest-publish

# Verifying Container Startup

The Peregrine Docker image implements the `HEALTHCHECK` instruction to determine if all
Expand Down
5 changes: 5 additions & 0 deletions docker/builddocker-remote-replication.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

./builddocker.sh author,notshared author
./builddocker.sh publish,notshared publish

11 changes: 10 additions & 1 deletion docker/builddocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@

./fetchfiles.sh

docker build --no-cache --tag=${DOCKER_IMAGE} .
export RUNMODE=$1
export DOCKER_IMAGE_WITH_TYPE=${DOCKER_IMAGE}-$2
if [ -z "$1" ]
then
export RUNMODE=none
export DOCKER_IMAGE_WITH_TYPE=${DOCKER_IMAGE}
fi

echo build docker image for runmode ${RUNMODE} using tag ${DOCKER_IMAGE_WITH_TYPE}
docker build --tag=${DOCKER_IMAGE_WITH_TYPE} --build-arg runmode=$RUNMODE .
4 changes: 4 additions & 0 deletions docker/pushdocker-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ if [ ${TRAVIS_PULL_REQUEST} != "false" ]; then
TAG="pr-${TRAVIS_PULL_REQUEST}"
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
docker tag "$DOCKER_IMAGE" "${DOCKER_IMAGE}:${TAG}"
docker tag "$DOCKER_IMAGE-author" "${DOCKER_IMAGE}-author:${TAG}"
docker tag "$DOCKER_IMAGE-publish" "${DOCKER_IMAGE}-publish:${TAG}"
docker push ${DOCKER_IMAGE}:${TAG}
docker push ${DOCKER_IMAGE}-author:${TAG}
docker push ${DOCKER_IMAGE}-publish:${TAG}
fi
15 changes: 14 additions & 1 deletion docker/scripts/install-peregrine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PACKAGE_DIR=/app/binaries
SAVE_PWD=`pwd`

echo "Starting Sling for the first time..."
/app/scripts/start.sh
/app/scripts/start.sh $1

echo "Installing Sling Packager"
npm install @peregrinecms/slingpackager -g
Expand All @@ -31,6 +31,19 @@ do
slingpackager -v upload --install ${PACKAGE_DIR}/$pkg
done

# Wait for Sling to be fully ready again
# added an extra sleep to make sure the last package install is completed (sling jobs may take a bit to run)
sleep 5
STATUS=$(curl -u admin:admin -s --fail http://localhost:8080/system/console/bundles.json | jq '.s[3:5]' -c)
if [ "$STATUS" != "[0,0]" ]; then
while [ "$STATUS" != "[0,0]" ]
do
echo "Sling still starting. Waiting for all bundles to be ready.."
sleep 5
STATUS=$(curl -u admin:admin -s --fail http://localhost:8080/system/console/bundles.json | jq '.s[3:5]' -c)
done
fi

#echo "Stopping Peregrine..."
#kill `ps -ef | grep org.apache.sling.feature.launcher.jar | grep -v grep | awk '{print $2}'`

Expand Down
7 changes: 5 additions & 2 deletions docker/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/bin/bash

echo starting sling with runmode $1

cd /app/sling && java -jar /app/sling/org.apache.sling.feature.launcher.jar \
-D sling.runmodes=none \
-D sling.run.modes=$1 \
-f /app/sling/com.peregrine-cms.sling.launchpad-12-SNAPSHOT-oak_tar_far.far \
-p /app/sling \
-c /app/sling/launcher/cache &

# Wait for Sling to fully start up
sleep 5
STATUS=$(curl -u admin:admin -s --fail http://localhost:8080/system/console/bundles.json | jq '.s[3:5]' -c)
if [ "$STATUS" != "[0,0]" ]; then
while [ "$STATUS" != "[0,0]" ]
do
echo "Sling still starting. Waiting for all bundles to be ready.."
STATUS=$(curl -u admin:admin -s --fail http://localhost:8080/system/console/bundles.json | jq '.s[3:5]' -c)
sleep 5
STATUS=$(curl -u admin:admin -s --fail http://localhost:8080/system/console/bundles.json | jq '.s[3:5]' -c)
done
fi
32 changes: 28 additions & 4 deletions docs/public/docker/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Linux path (not the mounted folders from Windows).
```bash
docker run -it -p 8080:8080 peregrinecms/peregrine-cms:develop-sling12
```

this command runs a docker container

- `-it`: log output to stdout in the container is forwarded to your console and console blocks until you hit `ctrl-c` to stop the container
- `-p 8080:8080`: Your local port 8080 is forwarded to the container port 8080

Expand All @@ -26,6 +28,7 @@ Use your browser to go to Peregrine-CMS (<http://localhost:8080>)
```bash
docker pull peregrinecms/peregrine-cms:develop-sling12
```

- `pull`: checks and pulls a new version from docker hub for the docker image

## Check out a PR with docker
Expand All @@ -43,22 +46,43 @@ docker run -it -p 8080:8080 peregrinecms/peregrine-cms:pr-{number}
```bash
docker run -rm -it -p 8080:8080 -p 8000:8000 --name peregrine peregrinecms/peregrine-cms:develop-sling12
```

- `--name peregrine`: we give our container a name (use `docker ps` to see all your running docker containers)
- ` -rm`: the additional `-rm` removes the docker container when we stop it and frees the name of the container
- `-rm`: the additional `-rm` removes the docker container when we stop it and frees the name of the container
- `-p 8000:8000`: in addition to port 8080, also forward port 8000 to the docker container

in a second shell/command line run

```bash
docker exec -it peregrine bash
```
in the docker container `peregrine` **exec**ute `bash`

in the docker container `peregrine` **exec**ute `bash`

once in the shell in the container run the following commands:
```

```bash
cd /apps/sling/staticreplication
npx httpserver -p 8000
```
We change the shell to the location where peregrine stores the html files at replication and then start a nodejs based webserver at that location.

We change the shell to the location where peregrine stores the html files at replication and then start a nodejs based webserver at that location.

Use your browser to go to the website (<http://localhost:8000>) or Peregrine-CMS (<http://localhost:8080>)

## Run Peregrine-CMS with an author and publish (stage and live) instance

```bash
docker run -d --rm --network=host --name peregrine-author peregrinecms/peregrine-cms-author:develop-sling12
docker run -d --rm -p 8180:8080 --name peregrine-publish peregrinecms/peregrine-cms-publish:develop-sling12
```

> `--network=host` makes the author docker instance use the host
network interface. By default, remote replication in peregrine
expects a publisher to be available on port 8180.

to stop the instances use

```bash
docker kill peregrine-author peregrine-publish
```
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,4 @@ public interface PerPage
* - null if no page was found
**/
public PerPage getPrevious();

/** Marks the given Page as modified **/
public void markAsModified();
}
Loading

0 comments on commit 5901bee

Please sign in to comment.