From 54489e0e4b7b428dad46379abfc6c824efe31363 Mon Sep 17 00:00:00 2001 From: Joeri Bekker Date: Thu, 22 Oct 2020 13:12:35 +0200 Subject: [PATCH] :fire: Cleanup unused files and texts. --- INSTALL.rst | 69 ++++---------------------------- bin/live2staging.sh | 70 --------------------------------- bin/live2staging_postimport.sql | 1 - bin/live2staging_settings.sh | 19 --------- bin/release_docker_image.sh | 64 ------------------------------ 5 files changed, 8 insertions(+), 215 deletions(-) delete mode 100644 bin/live2staging.sh delete mode 100644 bin/live2staging_postimport.sql delete mode 100644 bin/live2staging_settings.sh delete mode 100755 bin/release_docker_image.sh diff --git a/INSTALL.rst b/INSTALL.rst index 5f7a945d..6ef3f245 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -18,7 +18,7 @@ Prerequisites You need the following libraries and/or programs: -* `Python`_ 3.6 or above +* `Python`_ 3.7 or above * Python `Virtualenv`_ and `Pip`_ * `PostgreSQL`_ 10 or above * `Node.js`_ @@ -44,7 +44,7 @@ development machine. .. code-block:: bash - $ git clone git@github.com:maykinmedia/objecttypes.git + $ git clone git@github.com:maykinmedia/objecttypes-api.git $ cd objecttypes 3. Install all required libraries. @@ -169,7 +169,7 @@ The easiest way to get the project started is by using `Docker Compose`_. .. code-block:: bash - $ git clone git@github.com:maykinmedia/objecttypes.git + $ git clone git@github.com:maykinmedia/objecttypes-api.git Cloning into 'objecttypes'... ... @@ -180,8 +180,8 @@ The easiest way to get the project started is by using `Docker Compose`_. .. code-block:: bash $ docker-compose up -d - Starting objecttypes_db_1 ... done - Starting objecttypes_web_1 ... done + Starting objecttypes-api_db_1 ... done + Starting objecttypes-api_web_1 ... done It can take a while before everything is done. Even after starting the web container, the database might still be migrating. You can always check the @@ -189,19 +189,19 @@ The easiest way to get the project started is by using `Docker Compose`_. .. code-block:: bash - $ docker logs -f objecttypes_web_1 + $ docker logs -f objecttypes-api_web_1 3. Create an admin user and load initial data. If different container names are shown above, use the container name ending with ``_web_1``: .. code-block:: bash - $ docker exec -it objecttypes_web_1 /app/src/manage.py createsuperuser + $ docker exec -it objecttypes-api_web_1 /app/src/manage.py createsuperuser Username: admin ... Superuser created successfully. - $ docker exec -it objecttypes_web_1 /app/src/manage.py loaddata admin_index groups + $ docker exec -it objecttypes-api_web_1 /app/src/manage.py loaddata admin_index groups Installed 5 object(s) from 2 fixture(s) 4. Point your browser to ``http://localhost:8000/`` to access the project's @@ -247,59 +247,6 @@ all settings. $ docker exec -it objecttypes /app/src/manage.py createsuperuser -Building and publishing the image ---------------------------------- - -Using ``bin/release-docker-image``, you can easily build and tag the image. - -The script is based on git branches and tags - if you're on the ``master`` -branch and the current ``HEAD`` is tagged, the tag will be used as -``RELEASE_TAG`` and the image will be pushed. If you want to push the image -without a git tag, you can use the ``RELEASE_TAG`` envvar. - -The image will only be pushed if the ``JOB_NAME`` envvar is set. The image -will always be built, even if no envvar is set. The default release tag is -``latest``. - -Example usage: - -.. code-block:: bash - - JOB_NAME=publish RELEASE_TAG=dev ./bin/release-docker-image.sh - - -Staging and production -====================== - -Ansible is used to deploy test, staging and production servers. It is assumed -the target machine has a clean `Debian`_ installation. - -1. Make sure you have `Ansible`_ installed (globally or in the virtual - environment): - - .. code-block:: bash - - $ pip install ansible - -2. Navigate to the project directory, and install the Maykin deployment - submodule if you haven't already: - - .. code-block:: bash - - $ git submodule update --init - -3. Run the Ansible playbook to provision a clean Debian machine: - - .. code-block:: bash - - $ cd deployment - $ ansible-playbook .yml - -For more information, see the ``README`` file in the deployment directory. - -.. _Debian: https://www.debian.org/ -.. _Ansible: https://pypi.org/project/ansible/ - Settings ======== diff --git a/bin/live2staging.sh b/bin/live2staging.sh deleted file mode 100644 index 10cc52e1..00000000 --- a/bin/live2staging.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -# This script should be run on staging. -source live2staging_settings.sh - -# Script starts here -TMP_FILE="$PGSQL_PROD_DB_NAME-livedb.sql" -TMP_MEDIA_FILE="$PGSQL_PROD_DB_NAME-media.tgz" - -if [ -f $TMP_FILE ]; then - echo -n "Create new dump? [y/n] " - read -n 1 yesno -else - yesno="y" -fi -echo - -if [ "$yesno" == "y" ]; then - echo "Creating dump of production database, please wait..." - - PGSQLDUMP_PROD_CMD_ARGS="--dbname=postgresql://$PGSQL_PROD_USERNAME:$PGSQL_PROD_PASSWORD@127.0.0.1:5432/$PGSQL_PROD_DB_NAME " - PGSQLDUMP_PROD_CMD="pg_dump $PGSQLDUMP_PROD_CMD_ARGS > /srv/sites/$TMP_FILE" - - ssh $PGSQL_PROD_HOST "$PGSQLDUMP_PROD_CMD" - scp $PGSQL_PROD_HOST:/srv/sites/$TMP_FILE $TMP_FILE -fi - -echo -n "Continue loading database? [y/n] " -read -n 1 cont -if [ "$cont" == "n" ]; then - echo - exit -fi -echo - -sudo supervisorctl stop $SUPERVISOR_GROUP:* -sudo service cron stop - -echo "Loading dump of production database into staging, please wait..." -sudo su postgres --command="dropdb $PGSQL_STAGING_DB_NAME" -sudo su postgres --command="createdb $PGSQL_STAGING_DB_NAME --owner=$PGSQL_STAGING_USERNAME" -PGSQL_STAGING_CMD="psql -q --dbname=postgresql://$PGSQL_STAGING_USERNAME:$PGSQL_STAGING_PASSWORD@127.0.0.1:5432/$PGSQL_STAGING_DB_NAME " -$PGSQL_STAGING_CMD < $TMP_FILE - -echo "Modifying data on staging to work with production data..." -$PGSQL_STAGING_CMD < $PWD/live2staging_postimport.sql - -echo "Copying media files from production to staging..." -rsync -au $PGSQL_PROD_HOST:$PROD_MEDIA_PATH/ $STAGING_MEDIA_PATH/ - -sudo chmod -R g+rw $STAGING_PROJECT_PATH - -cd $STAGING_PROJECT_PATH -source env/bin/activate - -env/bin/python src/manage.py migrate -env/bin/python src/manage.py locate_translation_files -sudo service cron start -sudo supervisorctl start $SUPERVISOR_GROUP:* - -cd $PWD - -NOW=$(date +"%Y-%m-%d") -FILE="$PGSQL_PROD_DB_NAME-live2staging-$NOW.sql" - -if [ "$yesno" == "y" ]; then - echo "Storing dump as $FILE..." - cp "$PWD/$TMP_FILE" "$FILE" - gzip $FILE -fi diff --git a/bin/live2staging_postimport.sql b/bin/live2staging_postimport.sql deleted file mode 100644 index 84d23301..00000000 --- a/bin/live2staging_postimport.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE accounts_user SET email=CONCAT('notify+', REPLACE(email,'@','__at__'), '@maykin.nl'), password='pbkdf2_sha256$12000$pZphUuHkCDke$x8KlvmVInqS1ru9sGZ1tkDStNkMh1xYU1VaG6SHtHMw='; diff --git a/bin/live2staging_settings.sh b/bin/live2staging_settings.sh deleted file mode 100644 index 6d2d092a..00000000 --- a/bin/live2staging_settings.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Settings for live2staging.sh -PGSQL_STAGING_DB_NAME="" -PGSQL_STAGING_USERNAME="" -PGSQL_STAGING_PASSWORD="" - -PGSQL_PROD_DB_NAME="" -PGSQL_PROD_USERNAME="" -PGSQL_PROD_PASSWORD="" - -PGSQL_PROD_HOST="" # Example: john@server.nl - -# No trailing slash -PROD_MEDIA_PATH="" -STAGING_PROJECT_PATH="" -STAGING_MEDIA_PATH="$STAGING_PROJECT_PATH/media" - -SUPERVISOR_GROUP="" diff --git a/bin/release_docker_image.sh b/bin/release_docker_image.sh deleted file mode 100755 index 0ce84027..00000000 --- a/bin/release_docker_image.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -set -e # exit on error -set -x # echo commands - -CONTAINER_REPO=maykinmedia/objecttypes - -git_tag=$(git tag --points-at HEAD) &>/dev/null -git_branch=$(git rev-parse --abbrev-ref HEAD) - - -build_image() { - tag=$1 - docker build \ - --target production \ - -t ${CONTAINER_REPO}:$tag \ - -f Dockerfile . -} - -get_release_tag() { - if [[ -n "$git_tag" ]]; then - release_tag=$git_tag - else - release_tag=${RELEASE_TAG:-latest} - fi - echo $release_tag -} - -push_image() { - # JOB_NAME is set by Jenkins - # only push the image if running in CI - release_tag=$1 - if [[ -n "$JOB_NAME" ]]; then - docker push ${CONTAINER_REPO}:$release_tag - - # if this is a tag, and this is master -> push latest as well - if [[ -n "$git_tag" && $git_branch -eq "master" ]]; then - build_image latest - docker push ${CONTAINER_REPO}:latest - fi - - write_deploy_params - else - echo "Not pushing image, set the JOB_NAME envvar to push after building" - fi -} - -write_deploy_params() { - # if on jenkins AND it's a tagged release -> prepare deployment - if [[ -n "$JENKINS_URL" && -n "$git_tag" ]]; then - echo " -VERSION=${git_tag} -" > deployment-parameters - fi -} - - -if [[ -n "$git_tag" ]]; then - echo "Building image for git tag $git_tag" -fi - -release_tag=$(get_release_tag) -build_image $release_tag -push_image $release_tag