Trying to make staging a thing
This commit is contained in:
parent
a547a7119e
commit
c70503f91d
|
|
@ -7,6 +7,18 @@ build:
|
||||||
script:
|
script:
|
||||||
- docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) . -t "cmc:latest"
|
- docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) . -t "cmc:latest"
|
||||||
|
|
||||||
|
deploy_staging:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- cd /home/cmc/staging/
|
||||||
|
- git pull origin master
|
||||||
|
- echo "Run the new docker image"
|
||||||
|
- /home/cmc/cmc-sales/run_docker_stg.sh
|
||||||
|
environment:
|
||||||
|
name: staging
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
deploy_production:
|
deploy_production:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
script:
|
script:
|
||||||
|
|
@ -17,6 +29,6 @@ deploy_production:
|
||||||
- /home/cmc/cmc-sales/run_docker.sh
|
- /home/cmc/cmc-sales/run_docker.sh
|
||||||
environment:
|
environment:
|
||||||
name: production
|
name: production
|
||||||
|
when: manual
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
|
||||||
63
Dockerfile_stg
Normal file
63
Dockerfile_stg
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
# This is 99% the same as the prod one. I should do something smarter here.
|
||||||
|
|
||||||
|
FROM ubuntu:lucid
|
||||||
|
|
||||||
|
# Set environment variables.
|
||||||
|
ENV HOME /root
|
||||||
|
|
||||||
|
# Define working directory.
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
RUN sed -i 's/archive/old-releases/' /etc/apt/sources.list
|
||||||
|
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get -y upgrade
|
||||||
|
|
||||||
|
# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container.
|
||||||
|
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl php5-imap
|
||||||
|
|
||||||
|
# Enable apache mods.
|
||||||
|
#RUN php5enmod openssl
|
||||||
|
RUN a2enmod php5
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
RUN a2enmod headers
|
||||||
|
|
||||||
|
|
||||||
|
# Update the PHP.ini file, enable <? ?> tags and quieten logging.
|
||||||
|
# RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php5/apache2/php.ini
|
||||||
|
#RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php5/apache2/php.ini
|
||||||
|
|
||||||
|
ADD conf/php.ini /etc/php5/apache2/php.ini
|
||||||
|
|
||||||
|
# Manually set up the apache environment variables
|
||||||
|
ENV APACHE_RUN_USER www-data
|
||||||
|
ENV APACHE_RUN_GROUP www-data
|
||||||
|
ENV APACHE_LOG_DIR /var/log/apache2
|
||||||
|
ENV APACHE_LOCK_DIR /var/lock/apache2
|
||||||
|
ENV APACHE_PID_FILE /var/run/apache2.pid
|
||||||
|
|
||||||
|
ARG COMMIT
|
||||||
|
ENV COMMIT_SHA=${COMMIT}
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Update the default apache site with the config we created.
|
||||||
|
ADD conf/apache-vhost.conf /etc/apache2/sites-available/cmc-sales
|
||||||
|
ADD conf/ripmime /bin/ripmime
|
||||||
|
|
||||||
|
RUN chmod +x /bin/ripmime
|
||||||
|
RUN a2dissite 000-default
|
||||||
|
|
||||||
|
# Copy site into place.
|
||||||
|
ADD . /var/www/cmc-sales
|
||||||
|
ADD app/config/database_stg.php /var/www/cmc-sales/app/config/database.php
|
||||||
|
RUN mkdir /var/www/cmc-sales/app/tmp
|
||||||
|
RUN mkdir /var/www/cmc-sales/app/tmp/logs
|
||||||
|
RUN chmod -R 755 /var/www/cmc-sales/app/tmp
|
||||||
|
RUN chmod +x /var/www/cmc-sales/run_vault.sh
|
||||||
|
|
||||||
|
RUN a2ensite cmc-sales
|
||||||
|
|
||||||
|
# By default, simply start apache.
|
||||||
|
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||||
52
app/config/database_stg.php
Normal file
52
app/config/database_stg.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
//CakePHP is pretty awful. I was so foolish.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($_SERVER["SERVER_NAME"] == "localhost") {
|
||||||
|
|
||||||
|
|
||||||
|
class DATABASE_CONFIG {
|
||||||
|
|
||||||
|
var $default = array(
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'persistent' => false,
|
||||||
|
'host' => '172.17.0.1',
|
||||||
|
'login' => 'cmc',
|
||||||
|
'password' => 'cmc',
|
||||||
|
'database' => 'cmc',
|
||||||
|
'prefix' => '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
class DATABASE_CONFIG {
|
||||||
|
|
||||||
|
var $default = array(
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'persistent' => false,
|
||||||
|
'host' => '172.17.0.1',
|
||||||
|
'login' => 'staging',
|
||||||
|
'password' => 'stagingmoopwoopVerySecure',
|
||||||
|
'database' => 'staging',
|
||||||
|
'prefix' => '',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// there are no tests...
|
||||||
|
var $test = array(
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'persistent' => false,
|
||||||
|
'host' => 'localhost',
|
||||||
|
'login' => 'user',
|
||||||
|
'password' => 'password',
|
||||||
|
'database' => 'test_database_name',
|
||||||
|
'prefix' => '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,3 +2,4 @@
|
||||||
FILENAME=backups/backup_$(date +'%Y%m%d-%H%M%S').sql.gz
|
FILENAME=backups/backup_$(date +'%Y%m%d-%H%M%S').sql.gz
|
||||||
mysqldump cmc | gzip > $FILENAME
|
mysqldump cmc | gzip > $FILENAME
|
||||||
rclone copy $FILENAME gdrivebackups:database/
|
rclone copy $FILENAME gdrivebackups:database/
|
||||||
|
rclone sync cmc-sales/app/webroot/pdf gdrivebackups:pdf/
|
||||||
|
|
|
||||||
3
build_docker_stg.sh
Normal file
3
build_docker_stg.sh
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
ID=$(docker ps -f ancestor=cmc:staging -q)
|
||||||
|
docker kill $ID
|
||||||
|
docker build -f Dockerfile_stg . -t "cmc:stg"
|
||||||
|
|
@ -4,4 +4,4 @@ sleep 1
|
||||||
docker run -d -p 127.0.0.1:8888:80 \
|
docker run -d -p 127.0.0.1:8888:80 \
|
||||||
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/pdf,target=/var/www/cmc-sales/app/webroot/pdf \
|
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/pdf,target=/var/www/cmc-sales/app/webroot/pdf \
|
||||||
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/attachments_files,target=/var/www/cmc-sales/app/webroot/attachments_files \
|
--mount type=bind,source=/home/k/projects/cmc-sales/app/webroot/attachments_files,target=/var/www/cmc-sales/app/webroot/attachments_files \
|
||||||
cmc:latest
|
cmc:stg
|
||||||
|
|
|
||||||
9
run_docker_stg.sh
Executable file
9
run_docker_stg.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
ID=$(docker ps -q)
|
||||||
|
docker kill $ID
|
||||||
|
sleep 1
|
||||||
|
docker run -d -p 127.0.0.1:9999:80 \
|
||||||
|
--mount type=bind,source=/home/cmc/staging/app/webroot/pdf,target=/var/www/cmc-sales/app/webroot/pdf \
|
||||||
|
--mount type=bind,source=/home/cmc/staging/app/webroot/attachments_files,target=/var/www/cmc-sales/app/webroot/attachments_files \
|
||||||
|
--mount type=bind,source=/home/cmc/staging/vault/emails,target=/var/www/emails \
|
||||||
|
--mount type=bind,source=/home/cmc/staging/vault/vaultmsgs,target=/var/www/vaultmsgs \
|
||||||
|
cmc:stg
|
||||||
Loading…
Reference in a new issue