You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

116 lines
3.0 KiB

.PHONY: clean_env init_env clean_virtualenv install_packages clean install run all schema_seminar.pdf schema_all.pdf
PYTHON=python2.7
VE_VER=12.0.7
LOCAL_PYTHON=bin/python
all: install
clean: clean_env
veryclean: clean clean_virtualenv
install: virtualenv bin/python install_packages
# phony, but depends on file
make_env: ${LOCAL_PYTHON}
# phony, but fast repeated execution
install_packages: make_env
bin/pip install -r requirements.txt
# phony
clean_env:
rm -rf bin/ include/ lib/ local/ share/
rm -f pip-selfcheck.json
rm -f schema_seminar.pdf schema_all.pdf
# binary name representing set-up env
${LOCAL_PYTHON}: virtualenv
${PYTHON} virtualenv/virtualenv.py .
# directory name
virtualenv:
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-${VE_VER}.tar.gz
tar xvfz virtualenv-${VE_VER}.tar.gz
mv virtualenv-${VE_VER} virtualenv
rm virtualenv-${VE_VER}.tar.gz
# phony
clean_virtualenv:
rm -rf virtualenv/
run:
./manage.py runserver_plus
test:
./manage.py test -v2 seminar mamweb
# DB schemata
schema: schema_seminar.pdf schema_all.pdf
schema_seminar.pdf:
./manage.py graph_models seminar | dot -Tpdf > schema_seminar.pdf
schema_all.pdf:
./manage.py graph_models -a -g | dot -Tpdf > schema_all.pdf
# remote commands
TEST_USER=test-mam
TEST_SERVER=atrey.karlin.mff.cuni.cz
TEST_DIR=/home/test-mam/mamweb-test/
PROD_USER=test-mam
PROD_SERVER=atrey.karlin.mff.cuni.cz
PROD_DIR=/home/test-mam/mamweb-prod/
HEAD=`git log --color=never |head -1|sed 's/.*commit //'`
push_test:
@echo "Checking out commited HEAD (${HEAD}) state at ${TEST_SSH} ..."
git tag deploy-test-`date +%Y-%m-%d-%H-%M`-${USER}
git push --all
ssh ${TEST_USER}@${TEST_SERVER} -n -x "\
cd ${TEST_DIR} && \
git fetch --all && \
git checkout ${HEAD} -f && \
git clean -f && \
cp mamweb/settings_test.py mamweb/settings.py && \
make install && \
./manage.py collectstatic --noinput && \
./manage.py migrate --noinput && \
(chown -Rf :mam . || true ) && \
(chmod -Rf g+w . || true ) && \
echo "Reloading apache ... (You may have to start it manually on error!)" && \
~/etc/apache2/apache2ctl -k reload && \
echo Done."
@echo "Test pushed to ${TEST_SERVER}:${TEST_DIR} successfully."
push_prod:
@echo "Checking out commited HEAD (${HEAD}) state at ${PROD_SSH} ..."
git tag deploy-prod-`date +%Y-%m-%d-%H-%M`-${USER}
git push --all
ssh ${PROD_USER}@${PROD_SERVER} -n -x "\
echo "Stopping apache ... (You may have to start it manually on error!)" && \
~/etc/apache2/apache2ctl -k stop && \
cd ${PROD_DIR} && \
./backup_prod_db.sh && \
git fetch --all && \
git checkout ${HEAD} -f && \
git clean -f && \
cp mamweb/settings_prod.py mamweb/settings.py && \
make install && \
./manage.py collectstatic --noinput && \
./manage.py migrate --noinput && \
(chown -Rf :mam . || true ) && \
(chmod -Rf g+w . || true ) && \
echo "Starting apache ..." && \
~/etc/apache2/apache2ctl -k start && \
echo Done."
@echo "Deployed to ${PROD_SERVER}:${PROD_DIR} successfully."