Skip to content

Commit

Permalink
Needed to upgrade the application
Browse files Browse the repository at this point in the history
Add a build scrypt
  • Loading branch information
sbrunner committed Jun 21, 2019
1 parent 6ae65ad commit 069591c
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 34 deletions.
9 changes: 6 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ jobs:
docker build --target=checks
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=$(ci/release-tag) .
- run: >
docker build --tag=camptocamp/geomapfish-config-build docker/config
docker build --tag=camptocamp/geomapfish-config-build
--build-arg=VERSION=$(ci/release-tag) docker/config
# Build QGIS images
- run: >
Expand Down Expand Up @@ -145,7 +146,8 @@ jobs:
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=$(ci/release-tag) .
docker build --target=upgrader --tag=camptocamp/geomapfish-scaffolds \
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=$(ci/release-tag) .
docker build --tag=camptocamp/geomapfish-config-build:$(ci/release-tag) docker/config
docker build --tag=camptocamp/geomapfish-config-build:$(ci/release-tag) \
--build-arg=VERSION=$(ci/release-tag) docker/config
- run: ci/test-upgrade init ${HOME}/workspace
- run: ci/test-upgrade 240 ${HOME}/workspace
- run: ci/test-upgrade 25 ${HOME}/workspace
Expand Down Expand Up @@ -173,7 +175,8 @@ jobs:
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=$(ci/release-tag) .
docker build --target=upgrader --tag=camptocamp/geomapfish-scaffolds \
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=$(ci/release-tag) .
docker build --tag=camptocamp/geomapfish-config-build docker/config
docker build --tag=camptocamp/geomapfish-config-build \
--build-arg=VERSION=$(ci/release-tag) docker/config
docker build --target=runner --build-arg=VERSION=latest \
--tag=camptocamp/geomapfish-qgisserver:gmf${MAJOR_VERSION}-qgismaster \
docker/qgisserver
Expand Down
5 changes: 4 additions & 1 deletion ci/create-new-project
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ docker build --target=runner --tag=camptocamp/geomapfish:${TAG} \
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=${TAG} .
docker build --target=upgrader --tag=camptocamp/geomapfish-scaffolds:${TAG} \
--build-arg=MAJOR_VERSION=${MAJOR_VERSION} --build-arg=VERSION=${TAG} .
docker build --tag=camptocamp/geomapfish-config-build:${TAG} docker/config
docker build --tag=camptocamp/geomapfish-config-build:${TAG} \
--build-arg=VERSION=${TAG} docker/config
WORKSPACE=$1
if [ $# -ge 2 ]
then
Expand Down Expand Up @@ -37,6 +38,8 @@ then
cp ci/run-dc-logs ${WORKSPACE}/${PACKAGE}/ci
fi
cd ${WORKSPACE}/${PACKAGE}
echo 'PGHOST=db' >> .env.sample
echo 'PGHOST_SLAVE=db' >> .env.sample

# Init Git repository
git init
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose.override.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
environment:
POSTGRES_PASSWORD: www-data
POSTGRES_USER: www-data
POSTGRES_DB: testgeomapfishapp
POSTGRES_DB: gmf_testgeomapfishapp

externaldb:
image: camptocamp/geomapfish-test-external-db
Expand Down
3 changes: 3 additions & 0 deletions docker/config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM debian:stretch
LABEL maintainer Camptocamp "[email protected]"

ARG VERSION
ENV VERSION=$VERSION

RUN \
apt-get update && \
apt-get install --assume-yes --no-install-recommends gettext-base python3-pip python3-setuptools && \
Expand Down
2 changes: 1 addition & 1 deletion geoportal/c2cgeoportal_geoportal/scaffolds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def post(self, command, output_dir, vars_):
Overrides the base template class to print the next step.
"""

fix_executables(output_dir, ("bin/*",))
fix_executables(output_dir, ("bin/*", "build"))

return BaseTemplate.post(self, command, output_dir, vars_)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ DOCKER_TAG=latest
VISIBLE_WEB_HOST=localhost:8484
VISIBLE_WEB_PROTOCOL=https
VISIBLE_ENTRY_POINT=/
PGHOST=db
PGHOST_SLAVE=db
PGHOST=pg-cluster-master.exo.camptocamp.com
PGHOST_SLAVE=pg-cluster-master.exo.camptocamp.com
PGPORT=5432
PGUSER=www-data
PGPASSWORD=www-data
PGDATABASE={{package}}
PGDATABASE=gmf_{{package}}
PGSCHEMA=main
PGSCHEMA_STATIC=main_static
AUTHTKT_TIMEOUT=86400
Expand Down
31 changes: 31 additions & 0 deletions geoportal/c2cgeoportal_geoportal/scaffolds/create/build_tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e

function help {
echo Usage:
echo './build -> keep the curent .env if exists or use the .env.sample'
echo './build [env files...] -> use the ordered env files list'
exit 1
}

if [ $# -gt 0 ] && ( [ $1 == '-h' ] || [ $1 == '--help' ]
then
help
fi

set -x
docker build --tag=camptocamp/{{package}]-config \
--build-arg=PGSCHEMA=main .
docker build --tag=camptocamp/{{package}}-geoportal \
--build-arg=PGSCHEMA=main \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal

if [ $# -gt 0 ]
then
shift
echo "$@" > .env
else
if [ ! -f .env ]
then
cp .env.sample .env
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ default_project_file:
- tilegeneration/config\.yaml\.tmpl
- project\.yaml\.mako
- docker-compose\.yaml
- \.env\.mako
- setup\.py
- vars\.yaml
- Makefile
- \.env\.sample
- geoportal/setup\.py
- geoportal/vars\.yaml
- geoportal/Makefile
- geoportal/alembic\.yaml
- geoportal/demo_geoportal/__init__\.py
- README\.rst
- \.travis\.yml
- qgisserver/geomapfish\.yaml
exclude:
- geoportal/{{package}}_geoportal/static-ngeo/js/{{package}}module\.js
- mapserver/demo\.map\.tmpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,6 @@ vars:
slave:
- \w+ /printproxy/.* # The print proxy is never writing to the DB

environment:
- name: PGSCHEMA
default: main

runtime_environment:
- name: VISIBLE_WEB_HOST
default: localhost
Expand All @@ -724,6 +720,8 @@ runtime_environment:
- PGPASSWORD
- name: PGDATABASE
default: geomapfish
- name: PGSCHEMA
default: main
- name: PGSCHEMA_STATIC
default: main_static
- name: TINYOWS_URL
Expand Down
8 changes: 6 additions & 2 deletions geoportal/c2cgeoportal_geoportal/scripts/c2cupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ def files_to_move(self, element, prefix="", force=False):
print("Needed from version {}.".format(element["version"]))
if os.path.dirname(dst) != "":
os.makedirs(os.path.dirname(dst), exist_ok=True)
os.rename(src, dst)
try:
check_call(["git", "mv", src, dst])
except Exception as e:
print("[Warning] Git move error: {}.".format(e))
os.rename(src, dst)
return task_to_do

@Step(6)
Expand Down Expand Up @@ -596,7 +600,7 @@ def step10(self, step):

message = [
"The upgrade is nearly done, now you should:",
"- Build your application with ./upgrade finalise PACKAGE [DOCKER_TAG].",
"- Build your application with ./upgrade finalise [build arguments]",
"- Test your application on '{}'.".format(
self.project.get('application_url', '... missing ...')
)
Expand Down
18 changes: 3 additions & 15 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,10 @@ then
help
fi

if [ $1 == finalise ]
if [ $1 == '--finalise' ]
then
if [ $# -lt 2 ]
then
help
fi
package=$2
tag=
if [ $# -gt 2 ]
then
tag=:$3
fi

docker build --tag=camptocamp/${package}-config${tag} .
docker build --tag=camptocamp/${package}-geoportal${tag} \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
shift 2
./build "$@"

docker-compose down --remove-orphans || true
DOCKER_TAG=unexisting docker-compose pull --ignore-pull-failures
Expand Down

0 comments on commit 069591c

Please sign in to comment.