Skip to content

Instantly share code, notes, and snippets.

@silvae86
Forked from evelyne24/.dockerignore
Created June 29, 2018 15:44
Show Gist options
  • Save silvae86/21194a6c05744d23256f9a17b9dd4a73 to your computer and use it in GitHub Desktop.
Save silvae86/21194a6c05744d23256f9a17b9dd4a73 to your computer and use it in GitHub Desktop.
Docker-ize Connfa
Dockerfile
.git
.git*
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:vMG4swzYwNmeVbInCchcXSP/wwXxVXQRBW4tvBqqyZw=
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=mysql_server
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=array
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
API_PREFIX=api
API_DOMAIN=
API_VERSION=v2
API_DEBUG=true
API_CONDITIONAL_REQUEST=false
CMS_ADMIN_PASS=adminadmin123
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:vMG4swzYwNmeVbInCchcXSP/wwXxVXQRBW4tvBqqyZw=
APP_URL=http://127.0.0.1
DB_CONNECTION=mysql
DB_HOST=mysql_server
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=array
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
API_PREFIX=api
API_DOMAIN=
API_VERSION=v2
API_DEBUG=true
API_CONDITIONAL_REQUEST=false
CMS_ADMIN_PASS=adminadmin123

Connfa is an Open Source framework for conferences and events. Alongside mobile apps (Android and iOS) and a web app, it also offers a Content Management System and an integration server, written in PHP (Laravel).

This aims to wrap Connfa CMS and Integration Server into a Docker image, publicly available in Docker Hub to make it easier to get the server up and running and seed the database with test data, to be able to quicly asses the suitability of the framework.

#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
version: '3'
services:
mysql_server:
image: mysql:5.7
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE=homestead
- MYSQL_USER=homestead
- MYSQL_PASSWORD=secret
- MYSQL_RANDOM_ROOT_PASSWORD=true
connfa:
image: connfa-local
ports:
- "80:8000"
volumes:
- /tmp/apache-logs/:/var/log/apache2
links:
- mysql_server
env_file:
- ".env"
migrator:
image: connfa-migrator-local
links:
- mysql_server
env_file:
- ".env"
FROM joaorosilva/connfa:2.1.0
ENV INSTALL_DIR /var/www/laravel
# Now we can install Connfa!
WORKDIR $INSTALL_DIR
# Run Migration Commands
COPY migrate.sh .
# Run Migrations!
ENTRYPOINT "$INSTALL_DIR/migrate.sh"
FROM library/ubuntu:16.04
ENV INSTALL_DIR /var/www/laravel
ENV CONNFA_VERSION "2.0.1"
## for apt to be noninteractive
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true
# expose port
EXPOSE 8000
#install tzdata unattended
## preesed tzdata, update package index, upgrade packages and install needed software
RUN echo "tzdata tzdata/Areas select Europe" > /tmp/preseed.txt; \
echo "tzdata tzdata/Zones/Europe select Lisbon" >> /tmp/preseed.txt; \
debconf-set-selections /tmp/preseed.txt && \
apt-get update && \
apt-get install -y tzdata
## cleanup of files from setup
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# install PHP and laravel dependencies
RUN apt-get install -y mysql-server-5.7 mysql-client-5.7
# Change this timezone if you need
RUN unlink /etc/localtime
RUN echo "Europe/Lisbon" > /etc/timezone
#Now we can install the packages unattended
RUN dpkg-reconfigure -f noninteractive tzdata
RUN apt-get install -y php php7.0-curl php7.0-mbstring php7.0-json php7.0-fpm php7.0-xmlrpc php7.0-soap php7.0-gd php7.0-xml php7.0-cli php7.0-zip php7.0-mysql
#Install Composer
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
#Now we can install Connfa!
WORKDIR $INSTALL_DIR
# delete files
RUN rm -rf ./app ./vendor ./public ./config ./Parser ./resources
#copy cloned app
ADD ./connfa $INSTALL_DIR
COPY .env $INSTALL_DIR
# install dependencies
RUN composer update
# set permissions
RUN chmod a+rw $INSTALL_DIR
# Start app
ENTRYPOINT php artisan serve --host=0.0.0.0 --port=8000
#!/usr/bin/env bash
START_DIR=$(pwd)
cd joaorosilva-connfa
if cd connfa;
then
git pull;
else
git clone https://github.com/lemberg/connfa-integration-server.git connfa
cd connfa
fi
git checkout --force "2.0.1"
cd ..
docker build . --tag connfa-local
docker tag connfa-local joaorosilva/connfa:2.1.0
cd $START_DIR
cd joaorosilva-connfa-migrator
docker build . --tag connfa-migrator-local
docker tag connfa-local joaorosilva/connfa-migrator:2.1.0
cd $START_DIR
echo "now visit locahost:80"
echo "default username for logging in: admin@test.com. Password: adminadmin123"
docker-compose up
#!/bin/sh
#set -o xtrace
echo "Waiting for database to come up"
retries=20
until mysql --host=$DB_HOST --user=$DB_USERNAME --password=$DB_PASSWORD $DB_DATABASE; do
echo "Mysql is unavailable - sleeping"
echo "Connfa default user is 'admin' and password is $CMS_ADMIN_PASS."
sleep 3
retries=$((retries-=1))
if [ "$retries" -lt 0 ]
then
echo "retried $retries times. giving up!"
exit 1
else
echo "retries=$retries"
fi
done
echo "Mysql is up - executing migrations"
php artisan migrate
php artisan db:seed
php artisan password:change --name=admin --password=$CMS_ADMIN_PASS
echo "default username for logging in at http://127.0.0.1:8000: admin@test.com. Password: $CMS_ADMIN_PASS"
#!/usr/bin/env bash
./destroy_everything_docker.sh
./install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment