├── .github └── workflows │ └── docker.yaml ├── LICENSE ├── README.md ├── install.sh ├── novosga-1.x ├── Dockerfile ├── README.md ├── start.sh └── start_db.php ├── novosga-2.0 ├── Dockerfile ├── README.md ├── apache2 │ └── htaccess ├── crontab │ └── cron ├── start.sh └── supervisor │ ├── apache2.conf │ ├── cron.conf │ └── websocket.conf ├── novosga-2.1 ├── Dockerfile ├── README.md ├── apache2 │ └── htaccess ├── crontab │ └── cron ├── start.sh └── supervisor │ ├── apache2.conf │ └── cron.conf ├── novosga-2.2-standalone ├── Dockerfile ├── README.md ├── config │ ├── crontab │ └── supervisord.conf └── start.sh └── php-baseimage ├── Dockerfile └── build.sh /.github/workflows/docker.yaml: -------------------------------------------------------------------------------- 1 | name: Docker Build 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | version: 11 | - '2.0' 12 | - '2.1' 13 | - '2.2-standalone' 14 | steps: 15 | - name: Git Checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: Log in to the Container registry 19 | uses: docker/login-action@v2.1.0 20 | with: 21 | username: ${{ secrets.DOCKER_HUB_USER }} 22 | password: ${{ secrets.DOCKER_HUB_TOKEN }} 23 | 24 | - name: Build and push Docker image 25 | uses: docker/build-push-action@v4.0.0 26 | with: 27 | context: novosga-${{ matrix.version }}/ 28 | push: true 29 | tags: novosga/novosga:${{ matrix.version }} 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Rogério Alencar Lino Filho 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker 2 | 3 | NovoSGA docker files. 4 | 5 | ## Installation 6 | 7 | ### Via Shell Script 8 | Para instalar o sistema por meio do instalador automatico basta copiar o codigo abaixo 9 | e colar direto no terminal de seu servidor Ubuntu: 10 | 11 | ```bash 12 | curl -sSL https://raw.githubusercontent.com/novosga/docker/master/install.sh | bash 13 | ``` -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | # script para instalacao automatica 2 | # sistema SGA 3 | # versao 1.0 4 | # Eduardo Policarpo em 28/06/2023 5 | 6 | #!/bin/bash 7 | 8 | # Função para instalar o Docker 9 | install_docker() { 10 | sudo apt update -y || { echo "Erro ao atualizar os pacotes."; exit 1; } 11 | sudo apt install -y apt-transport-https ca-certificates curl software-properties-common 12 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 13 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 14 | sudo apt update -y 15 | apt-cache policy docker-ce 16 | sudo apt install -y docker-ce 17 | } 18 | 19 | # Função para instalar o Docker Compose 20 | install_docker_compose() { 21 | sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | 22 | grep 'tag_name' | cut -d '"' -f 4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 23 | sudo chmod +x /usr/local/bin/docker-compose 24 | } 25 | 26 | # Verificar se o Docker está instalado 27 | if ! command -v docker >/dev/null 2>&1; then 28 | echo -e "\033[1;32m"'INSTALANDO DOCKER ...'"\e[0m" 29 | install_docker 30 | fi 31 | 32 | # Verificar se o Docker Compose está instalado 33 | if ! command -v docker-compose >/dev/null 2>&1; then 34 | echo -e "\033[1;32m"'INSTALANDO DOCKER COMPOSE ...'"\e[0m" 35 | install_docker_compose 36 | fi 37 | 38 | # Função genérica para perguntas interativas 39 | ask_question() { 40 | local question="$1" 41 | local var_name="$2" 42 | local input 43 | 44 | while true; do 45 | read -p "$(tput setaf 3)$question$(tput sgr0)" input 46 | if [[ -z $input ]]; then 47 | echo -e "$(tput setaf 1)É obrigatório preencher este campo.$(tput sgr0)" 48 | else 49 | eval "$var_name=\"$input\"" 50 | break 51 | fi 52 | done 53 | } 54 | 55 | # Nome de usuário do administrador 56 | ask_question "Defina o nome de usuário do administrador: " NOVOSGA_ADMIN_USERNAME 57 | 58 | # Senha do administrador 59 | ask_question "Defina a senha do administrador (mínimo 6 caracteres): " NOVOSGA_ADMIN_PASSWORD 60 | 61 | # Senha do MySQL 62 | ask_question "Defina a senha do banco de dados MySQL: " MYSQL_PASSWORD 63 | 64 | # Primeiro nome do administrador 65 | ask_question "Defina o primeiro nome do administrador: " NOVOSGA_ADMIN_FIRSTNAME 66 | 67 | # Sobrenome do administrador 68 | ask_question "Defina o sobrenome do administrador: " NOVOSGA_ADMIN_LASTNAME 69 | 70 | # Nome da unidade 71 | ask_question "Defina o nome da unidade: " NOVOSGA_UNITY_NAME 72 | 73 | # Código da unidade 74 | ask_question "Defina o código da unidade: " NOVOSGA_UNITY_CODE 75 | 76 | # Nome da prioridade normal 77 | ask_question "Defina o nome da prioridade normal: " NOVOSGA_NOPRIORITY_NAME 78 | 79 | # Descrição da prioridade normal 80 | ask_question "Defina a descrição da prioridade normal: " NOVOSGA_NOPRIORITY_DESCRIPTION 81 | 82 | # Nome da prioridade 83 | ask_question "Defina o nome da prioridade: " NOVOSGA_PRIORITY_NAME 84 | 85 | # Descrição da prioridade 86 | ask_question "Defina a descrição da prioridade: " NOVOSGA_PRIORITY_DESCRIPTION 87 | 88 | # Nome do local 89 | ask_question "Defina o nome do local: " NOVOSGA_PLACE_NAME 90 | 91 | # Criação dinâmica do conteúdo do docker-compose.yml em uma variável 92 | docker_compose=$(cat < docker-compose.yml 134 | 135 | # Executar docker-compose up -d e cria o container do sistema 136 | docker-compose up -d 137 | -------------------------------------------------------------------------------- /novosga-1.x/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM composer/composer:1.1-php5-alpine as build 2 | 3 | ENV NOVOSGA_VER=v1.5.1 \ 4 | NOVOSGA_MD5=a201469188d7209c20a473f34a1c2d21 5 | 6 | ENV NOVOSGA_FILE=novosga.tar.gz \ 7 | NOVOSGA_DIR=/var/www/html \ 8 | NOVOSGA_URL=https://github.com/novosga/novosga/archive/${NOVOSGA_VER}.tar.gz 9 | 10 | WORKDIR $NOVOSGA_DIR 11 | 12 | RUN set -xe \ 13 | && apk add --no-cache gettext-dev gettext tar \ 14 | && docker-php-ext-install gettext \ 15 | && docker-php-ext-install pcntl \ 16 | && curl -fSL ${NOVOSGA_URL} -o ${NOVOSGA_FILE} \ 17 | && echo "${NOVOSGA_MD5} ${NOVOSGA_FILE}" | md5sum -c \ 18 | && tar -xz --strip-components=1 -f ${NOVOSGA_FILE} \ 19 | && rm ${NOVOSGA_FILE} \ 20 | && composer install --no-dev 21 | 22 | FROM php:5.6.24-apache 23 | 24 | EXPOSE 80 25 | 26 | RUN echo 'session.save_path = "/tmp"' > /usr/local/etc/php/conf.d/sessionsavepath.ini && \ 27 | echo 'date.timezone = ${TZ}' > /usr/local/etc/php/conf.d/datetimezone.ini 28 | 29 | RUN apt-get update \ 30 | && apt-get install -y postgresql-server-dev-all --no-install-recommends \ 31 | && docker-php-ext-install gettext pdo_mysql pdo_pgsql \ 32 | && a2enmod rewrite \ 33 | && apt-get remove -y --purge postgresql-server-dev-all \ 34 | && apt-get clean \ 35 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 36 | 37 | COPY --from=build /var/www/html /var/www/html 38 | 39 | RUN echo "RedirectMatch ^/$ /public" > .htaccess \ 40 | && chown -R 33:33 /var/www/html 41 | 42 | #set default env vars 43 | ENV TZ="UTC" \ 44 | DATABASE_NAME="novosga" \ 45 | NOVOSGA_ADMIN_USERNAME="admin" \ 46 | NOVOSGA_ADMIN_FIRSTNAME="Administrator" \ 47 | NOVOSGA_ADMIN_LASTNAME="Global" \ 48 | NOVOSGA_ADMIN_PASSWORD="123456" \ 49 | DATABASE_PORT="3306" 50 | 51 | COPY start.sh /bin 52 | 53 | COPY start_db.php /bin 54 | 55 | CMD ["start.sh"] 56 | -------------------------------------------------------------------------------- /novosga-1.x/README.md: -------------------------------------------------------------------------------- 1 | # novosga 1.x 2 | From novosga docs: 3 | SGA é o acrônimo de Sistema de Gerenciamento de Atendimento, um sistema adaptável para grandes e pequenas organizações. 4 | 5 | Através do SGA é possível gerenciar filas e fluxo de atendimento em quaisquer tipos de empresas ou organizações que prestam serviço de atendimento presencial à pessoas. 6 | 7 | O SGA oferece o controle de filas de atendimento através de emissão de senhas e chamada das mesmas através de painéis. As filas de atendimento podem conter um único serviço ou um grupo de serviços. Os painéis podem chamar um, vários ou todos os serviços. Uma unidade de atendimento pode ter vários painéis. 8 | 9 | O SGA é mais do que um sistema de controle de filas.Ao gerenciar o fluxo de atendimento, o sistema apresenta uma série de recursos que auxiliam na gerência e administração das unidades de atendimento. 10 | 11 | Fornece uma diversidade de informações gerenciais preciosas, através de relatórios, estatísticas e gráficos avançados sobre atendimentos de uma unidade, de um grupo de unidades ou de todas elas. É possível obter estatísticas e tempos médios de atendimento por atendente, por período e por unidade, entre outras. Pode-se obter dados detalhados ou agregados. 12 | 13 | As informações gerenciais fornecidas pelo SGA possibilitam aos gestores planejar, acompanhar, monitorar, otimizar e agilizar o atendimento aos clientes. O sistema pode ser utilizado tanto de forma centralizada como descentralizada. Ou seja, pode-se utilizar servidores hospedados centralizadamente ou em cada unidade de atendimento. Porém, o ambiente centralizado oferece mais vantagens, pois os dados estarão concentrados num mesmo banco de dados, possibilitando emitir relatórios e estatísticas completas. 14 | 15 | Na versão Novo SGA, a parte web foi totalmente reformulada, deixando mais leve e intuitiva, com uma interface amigável e instalação super fácil. Já no painel, além de melhorias para funcionar em monitores widescreen, foi reescrito em JavaFX. 16 | 17 | ## How to use 18 | ``` 19 | docker container run -d \ 20 | -e DATABASE_HOST="hostname" \ 21 | -e DATABASE_USER="dbusername" \ 22 | -e DATABASE_PASSWORD="dbpass" \ 23 | -e DATABASE_SGDB="mysql or postgres" \ 24 | -p 80:80 \ 25 | novosga/novosga:1.x 26 | ``` 27 | 28 | 29 | ### Settings (Environment Variables) 30 | 31 | | Setting | Default value | Optional? | 32 | | ----------------------- | ------------------- | :-------: | 33 | | DATABASE_HOST | *blank* | ***no*** | 34 | | DATABASE_NAME | novosga | yes | 35 | | DATABASE_USER | *blank* | ***no*** | 36 | | DATABASE_PASSWORD | *blank* | ***no*** | 37 | | DATABASE_SGDB | *blank* | ***no*** | 38 | | DATABASE_PORT | 3306 | yes | 39 | | NOVOSGA_ADMIN_USERNAME | admin | yes | 40 | | NOVOSGA_ADMIN_FIRSTNAME | Administrator | yes | 41 | | NOVOSGA_ADMIN_LASTNAME | Global | yes | 42 | | NOVOSGA_ADMIN_PASSWORD | 123456 | yes | 43 | | TZ | UTC | yes | 44 | -------------------------------------------------------------------------------- /novosga-1.x/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | WORKDIR="/var/www/html" 4 | 5 | # DATABASE_HOST=mysqldb DATABASE_NAME=novosga DATABASE_USER=root DATABASE_PASSWORD=teste DATABASE_DRIVER=mysql NOVOSGA_ADMIN_USERNAME="admin" NOVOSGA_ADMIN_FIRSTNAME="fulano" NOVOSGA_ADMIN_LASTNAME="beltrano sicrano" NOVOSGA_ADMIN_PASSWORD="teste" VERSION="1.5.0" DATABASE_SGDB=mysql PORT=3306 teste/start.sh 6 | 7 | echo "Starting pre-flight check... " 8 | 9 | echo -n "Database driver: " 10 | case $DATABASE_SGDB in 11 | mysql) 12 | export DATABASE_DRIVER="pdo_mysql" 13 | echo "Ok, set as mysql" 14 | ;; 15 | postgres) 16 | export DB_DRIVER="pdo_postgres" 17 | echo "Ok, set as postgres" 18 | ;; 19 | *) 20 | echo "Error - SGDB must be either 'mysql' or 'postgres'" 21 | exit 1 22 | ;; 23 | esac 24 | 25 | echo -n "Database host: " 26 | if [ -z "$DATABASE_HOST" ]; then 27 | echo "You need to tell me where to find the database with DB_HOST" 28 | exit 1 29 | fi 30 | echo "Ok" 31 | 32 | echo -n "Database user: " 33 | if [ -z "$DATABASE_USER" ]; then 34 | echo "You need to tell me the user to connect to your database with DB_USER" 35 | exit 1 36 | fi 37 | echo "Ok" 38 | 39 | 40 | echo -n "Database password: " 41 | if [ -z "$DATABASE_PASSWORD" ]; then 42 | echo "You neet to tell me the password to connect to your database with DB_PASSWORD" 43 | exit 1 44 | fi 45 | echo "Ok" 46 | 47 | echo "Pre-flight check done" 48 | 49 | cat >$WORKDIR/config/database.php < "$DATABASE_DRIVER", 53 | "host" => "$DATABASE_HOST", 54 | "port" => "$DATABASE_PORT", 55 | "user" => "$DATABASE_USER", 56 | "password" => "$DATABASE_PASSWORD", 57 | "dbname" => "$DATABASE_NAME", 58 | "charset" => "utf8", 59 | ); 60 | EOF 61 | 62 | #get the version of the app :) 63 | export VERSION=$(grep 'VERSION =' src/Novosga/App.php | sed -r 's/[^0-9.]*([0-9.]+)[^0-9.]*/\1/') 64 | 65 | start_db.php 66 | 67 | echo "Setup is done, starting Apache..." 68 | exec apache2-foreground 69 | -------------------------------------------------------------------------------- /novosga-1.x/start_db.php: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/php 2 | 3 | $v) { 8 | $str = str_replace('{'.$k.'}', $v, $str); 9 | } 10 | return $str; 11 | } 12 | 13 | $conn = new PDO (getenv("DATABASE_SGDB").':host='.getenv("DATABASE_HOST").';dbname='.getenv("DATABASE_NAME"), getenv("DATABASE_USER"), getenv("DATABASE_PASSWORD")); 14 | 15 | if($query = $conn->query('select valor from config where chave="version"')) { 16 | echo "Updating DB schema: "; 17 | $versaoatual = $query->fetchObject()->valor; 18 | $arquivosmigracao="/var/www/html/src/Novosga/Install/sql/migration"; 19 | $arquivos=glob("$arquivosmigracao/*.sql"); 20 | foreach ($arquivos as $arquivo) { 21 | $versaomig = str_replace('.sql', '', basename($arquivo)); 22 | if ( $versaomig <= getenv("VERSION") && $versaomig > $versaoatual ) 23 | $conn->exec($arquivo); 24 | } 25 | //migrating or not, we need to update the version (if its the same it will only match) 26 | $conn->query('update config set valor = "'.getenv("VERSION").'" where chave = "version";'); 27 | echo "Ok\n"; 28 | } 29 | else { 30 | echo "Setting DB Schema: "; 31 | $conn->exec(file_get_contents('/var/www/html/src/Novosga/Install/sql/create/'.getenv("DATABASE_SGDB").'.sql')); 32 | echo "Ok\n"; 33 | 34 | echo "Installing modules: "; 35 | $moddir = "/var/www/html/modules/sga/"; 36 | $modules = array_diff(scandir($moddir), array('.', '..')); 37 | 38 | foreach ($modules as $module) { 39 | exec("php /var/www/html/bin/novosga.php module:install ".$moddir.$module." sga.".$module); 40 | } 41 | $conn->query('update modulos set status = 1'); 42 | echo "Ok\n"; 43 | 44 | 45 | echo "Inserting default data: "; 46 | $adm['login'] = getenv("NOVOSGA_ADMIN_USERNAME"); 47 | $adm['nome'] = getenv("NOVOSGA_ADMIN_FIRSTNAME"); 48 | $adm['sobrenome'] = getenv("NOVOSGA_ADMIN_LASTNAME"); 49 | $adm['senha'] = md5(getenv("NOVOSGA_ADMIN_PASSWORD")); 50 | 51 | $sql = format(file_get_contents('/var/www/html/src/Novosga/Install/sql/data/default.sql'), $adm); 52 | 53 | $conn->exec($sql); 54 | $conn->query('insert into config (chave, valor, tipo) values ("version", "'.getenv("VERSION").'", 1)'); 55 | echo "Ok\n"; 56 | } 57 | 58 | ?> 59 | -------------------------------------------------------------------------------- /novosga-2.0/Dockerfile: -------------------------------------------------------------------------------- 1 | #Build stage, useful for a better use of cache ;) 2 | FROM composer:1.7.0 AS build 3 | 4 | ENV NOVOSGA_VER=v2.0.11 5 | ENV NOVOSGA_FILE=novosga.tar.gz \ 6 | NOVOSGA_DIR=/var/www/html \ 7 | NOVOSGA_URL=https://github.com/novosga/novosga/archive/${NOVOSGA_VER}.tar.gz \ 8 | APP_ENV=prod \ 9 | DATABASE_URL=mysql://127.0.0.1:3306/novosga?charset=utf8mb4&serverVersion=5.7 10 | 11 | RUN set -xe \ 12 | && mkdir -p $NOVOSGA_DIR && cd $NOVOSGA_DIR \ 13 | && docker-php-ext-install pcntl \ 14 | && curl -fSL ${NOVOSGA_URL} -o ${NOVOSGA_FILE} \ 15 | && tar -xz --strip-components=1 -f ${NOVOSGA_FILE} \ 16 | && rm ${NOVOSGA_FILE} \ 17 | && composer install --no-dev -o 18 | 19 | FROM php:7.1-apache 20 | 21 | RUN set -xe \ 22 | && apt-get update \ 23 | && apt-get install -y \ 24 | cron \ 25 | libicu-dev \ 26 | libxml2-dev \ 27 | zlib1g-dev \ 28 | supervisor \ 29 | && docker-php-ext-install \ 30 | intl \ 31 | pcntl \ 32 | pdo \ 33 | pdo_mysql \ 34 | xml \ 35 | zip \ 36 | && apt-get remove -y --purge \ 37 | postgresql-server-dev-all \ 38 | libicu-dev \ 39 | libxml2-dev \ 40 | zlib1g-dev \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 43 | && a2enmod rewrite env \ 44 | && echo 'session.save_path = "/tmp"' > /usr/local/etc/php/conf.d/sessionsavepath.ini \ 45 | && echo 'date.timezone = ${TZ}' > /usr/local/etc/php/conf.d/datetimezone.ini 46 | 47 | COPY --from=build /var/www/html /var/www/html 48 | 49 | RUN set -xe \ 50 | && chown -R www-data:www-data . \ 51 | && sed -i 's|/var/www/html|/var/www/html/public|g' /etc/apache2/sites-available/000-default.conf 52 | 53 | #Set the default parameters 54 | ENV APP_ENV=prod \ 55 | LANGUAGE=pt_BR \ 56 | NOVOSGA_ADMIN_USERNAME="admin" \ 57 | NOVOSGA_ADMIN_PASSWORD="123456" \ 58 | NOVOSGA_ADMIN_FIRSTNAME="Administrador" \ 59 | NOVOSGA_ADMIN_LASTNAME="Global" \ 60 | NOVOSGA_UNITY_NAME="Minha Unidade" \ 61 | NOVOSGA_UNITY_CODE="U01" \ 62 | NOVOSGA_NOPRIORITY_NAME="Normal" \ 63 | NOVOSGA_NOPRIORITY_DESCRIPTION="Serviço normal" \ 64 | NOVOSGA_PRIORITY_NAME="Prioridade" \ 65 | NOVOSGA_PRIORITY_DESCRIPTION="Serviço prioritário" \ 66 | NOVOSGA_PLACE_NAME="Guichê" 67 | 68 | COPY start.sh /usr/local/bin 69 | COPY apache2/htaccess public/.htaccess 70 | COPY supervisor/apache2.conf /etc/supervisor/conf.d/apache2.conf 71 | COPY supervisor/cron.conf /etc/supervisor/conf.d/cron.conf 72 | COPY supervisor/websocket.conf /etc/supervisor/conf.d/websocket.conf 73 | 74 | ADD crontab/cron /etc/cron.d/app 75 | RUN chmod 644 /etc/cron.d/app 76 | 77 | CMD ["start.sh"] 78 | -------------------------------------------------------------------------------- /novosga-2.0/README.md: -------------------------------------------------------------------------------- 1 | # NovoSGA 2.0 2 | 3 | ## Docker image milestones 4 | 5 | - [x] Pre-flight check 6 | - [x] Auto setup 7 | - [x] Daily ticket reset at 1am 8 | - [ ] docker secrets support 9 | 10 | ## How to use 11 | 12 | The container will check if the required settings are set and will start the database setup automatically. 13 | You can set the system as you like with environment variables (using docker-compose.yml or `-e` flags at `docker container run`) 14 | 15 | ### Settings (environment variables) 16 | 17 | | Option | Default setting | Description | Optional? | 18 | | ------------------------------ | ----------------- | -------------------------------- | :-------: | 19 | | APP_ENV | prod | Environment running the app | yes | 20 | | DATABASE_URL | *blank* | Database connection string | ***no*** | 21 | | NOVOSGA_ADMIN_USERNAME | admin | Admin username | yes | 22 | | NOVOSGA_ADMIN_PASSWORD | 123456 | Admin password | yes | 23 | | NOVOSGA_ADMIN_FIRSTNAME | Administrator | Administrator first name | yes | 24 | | NOVOSGA_ADMIN_LASTNAME | Global | Administrador last name | yes | 25 | | NOVOSGA_UNITY_NAME | My Unity | Unity name | yes | 26 | | NOVOSGA_UNITY_CODE | U01 | Unity code | yes | 27 | | NOVOSGA_NOPRIORITY_DESCRIPTION | Normal service | Non-Priority service description | yes | 28 | | NOVOSGA_PRIORITY_NAME | Priority | Priority service name | yes | 29 | | NOVOSGA_PRIORITY_DESCRIPTION | Priority service | Priority service description | yes | 30 | | NOVOSGA_PLACE_NAME | Box | Place name | yes | 31 | | TZ | UTC | Timezone | yes | 32 | 33 | ## Documentation 34 | 35 | https://novosga.org/docs/#/2.0/install-docker 36 | -------------------------------------------------------------------------------- /novosga-2.0/apache2/htaccess: -------------------------------------------------------------------------------- 1 | Options -MultiViews 2 | RewriteEngine On 3 | RewriteCond %{REQUEST_FILENAME} !-f 4 | RewriteRule ^(.*)$ index.php [QSA,L] 5 | PassEnv APP_ENV 6 | PassEnv DATABASE_URL 7 | PassEnv DATABASE_PASS 8 | PassEnv TRUSTED_PROXIES 9 | PassEnv TRUSTED_HOSTS 10 | -------------------------------------------------------------------------------- /novosga-2.0/crontab/cron: -------------------------------------------------------------------------------- 1 | # m h dom mon dow command 2 | 0 1 * * * root /usr/local/bin/php /var/www/html/bin/console novosga:reset > /var/log/novosga-reset.log 2>&1 3 | -------------------------------------------------------------------------------- /novosga-2.0/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Starting pre-flight check..." 3 | 4 | echo -n "Database url: " 5 | if [ -z "$DATABASE_URL" ]; then 6 | echo "\nYou need to tell me where the database is and how to connect to it by setting DATABASE_URL environment variable" 7 | echo "e.g.: Using the flag -e DATABASE_URL='mysql://user:pass@127.0.0.1:3306/dbname?charset=utf8mb4&serverVersion=5.7' at docker container run" 8 | exit 1 9 | fi 10 | echo "Ok" 11 | 12 | bin/console cache:clear --no-debug --no-warmup 13 | bin/console cache:warmup 14 | 15 | # we need to wait until the database is up and accepting connections 16 | until bin/console -q doctrine:query:sql "select version()" > /dev/null 2>&1; do 17 | echo "Waiting for database..."; 18 | sleep 5; 19 | done 20 | 21 | echo "Database is up, configuring schema" 22 | 23 | set -xe 24 | 25 | # Copy env vars to environment file (for cron usage) 26 | printenv >> /etc/environment 27 | 28 | # Install/Updates the database schema 29 | /var/www/html/bin/console novosga:install 30 | 31 | echo "Setup done! Starting apache" 32 | exec /usr/bin/supervisord -n 33 | -------------------------------------------------------------------------------- /novosga-2.0/supervisor/apache2.conf: -------------------------------------------------------------------------------- 1 | [program:apache2] 2 | command = apache2-foreground 3 | stdout_logfile = /var/log/novosga-apache2.log 4 | stderr_logfile = /var/log/novosga-apache2-error.log 5 | -------------------------------------------------------------------------------- /novosga-2.0/supervisor/cron.conf: -------------------------------------------------------------------------------- 1 | [program:cron] 2 | command = cron -f 3 | 4 | -------------------------------------------------------------------------------- /novosga-2.0/supervisor/websocket.conf: -------------------------------------------------------------------------------- 1 | [program:websocket] 2 | command = /var/www/html/bin/console novosga:websocket start 3 | stdout_logfile = /var/log/novosga-websocket.log 4 | stderr_logfile = /var/log/novosga-websocket-error.log 5 | -------------------------------------------------------------------------------- /novosga-2.1/Dockerfile: -------------------------------------------------------------------------------- 1 | #Build stage, useful for a better use of cache ;) 2 | FROM composer:1.7.0 AS build 3 | 4 | ENV NOVOSGA_VER=v2.1.9 5 | ENV NOVOSGA_FILE=novosga.tar.gz \ 6 | NOVOSGA_DIR=/var/www/html \ 7 | NOVOSGA_URL=https://github.com/novosga/novosga/archive/${NOVOSGA_VER}.tar.gz \ 8 | APP_ENV=prod \ 9 | DATABASE_URL=mysql://127.0.0.1:3306/novosga?charset=utf8mb4&serverVersion=5.7 10 | 11 | RUN set -xe \ 12 | && mkdir -p $NOVOSGA_DIR && cd $NOVOSGA_DIR \ 13 | && docker-php-ext-install pcntl \ 14 | && curl -fSL ${NOVOSGA_URL} -o ${NOVOSGA_FILE} \ 15 | && tar -xz --strip-components=1 -f ${NOVOSGA_FILE} \ 16 | && rm ${NOVOSGA_FILE} \ 17 | && composer install --no-dev -o 18 | 19 | FROM php:7.2-apache 20 | 21 | RUN set -xe \ 22 | && apt-get update \ 23 | && apt-get install -y \ 24 | cron \ 25 | libicu-dev \ 26 | libxml2-dev \ 27 | zlib1g-dev \ 28 | supervisor \ 29 | && docker-php-ext-install \ 30 | intl \ 31 | pcntl \ 32 | pdo \ 33 | pdo_mysql \ 34 | xml \ 35 | zip \ 36 | && apt-get remove -y --purge \ 37 | postgresql-server-dev-all \ 38 | libicu-dev \ 39 | libxml2-dev \ 40 | zlib1g-dev \ 41 | && apt-get clean \ 42 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 43 | && a2enmod rewrite env \ 44 | && echo 'session.save_path = "/tmp"' > /usr/local/etc/php/conf.d/sessionsavepath.ini \ 45 | && echo 'date.timezone = ${TZ}' > /usr/local/etc/php/conf.d/datetimezone.ini 46 | 47 | COPY --from=build /var/www/html /var/www/html 48 | 49 | RUN set -xe \ 50 | && chown -R www-data:www-data . \ 51 | && sed -i 's|/var/www/html|/var/www/html/public|g' /etc/apache2/sites-available/000-default.conf 52 | 53 | #Set the default parameters 54 | ENV APP_ENV=prod \ 55 | LANGUAGE=pt_BR \ 56 | NOVOSGA_ADMIN_USERNAME="admin" \ 57 | NOVOSGA_ADMIN_PASSWORD="123456" \ 58 | NOVOSGA_ADMIN_FIRSTNAME="Administrador" \ 59 | NOVOSGA_ADMIN_LASTNAME="Global" \ 60 | NOVOSGA_UNITY_NAME="Minha Unidade" \ 61 | NOVOSGA_UNITY_CODE="U01" \ 62 | NOVOSGA_NOPRIORITY_NAME="Normal" \ 63 | NOVOSGA_NOPRIORITY_DESCRIPTION="Serviço normal" \ 64 | NOVOSGA_PRIORITY_NAME="Prioridade" \ 65 | NOVOSGA_PRIORITY_DESCRIPTION="Serviço prioritário" \ 66 | NOVOSGA_PLACE_NAME="Guichê" 67 | 68 | COPY start.sh /usr/local/bin 69 | COPY apache2/htaccess public/.htaccess 70 | COPY supervisor/apache2.conf /etc/supervisor/conf.d/apache2.conf 71 | COPY supervisor/cron.conf /etc/supervisor/conf.d/cron.conf 72 | 73 | ADD crontab/cron /etc/cron.d/app 74 | RUN chmod 644 /etc/cron.d/app 75 | 76 | CMD ["start.sh"] 77 | -------------------------------------------------------------------------------- /novosga-2.1/README.md: -------------------------------------------------------------------------------- 1 | # NovoSGA 2.1 2 | 3 | ## Docker image milestones 4 | 5 | - [x] Pre-flight check 6 | - [x] Auto setup 7 | - [x] Daily ticket reset at 1am 8 | - [ ] docker secrets support 9 | 10 | ## How to use 11 | 12 | The container will check if the required settings are set and will start the database setup automatically. 13 | You can set the system as you like with environment variables (using docker-compose.yml or `-e` flags at `docker container run`) 14 | 15 | ### Settings (environment variables) 16 | 17 | | Option | Default setting | Description | Optional? | 18 | | ------------------------------ | ----------------- | -------------------------------- | :-------: | 19 | | APP_ENV | prod | Environment running the app | yes | 20 | | DATABASE_URL | *blank* | Database connection string | ***no*** | 21 | | NOVOSGA_ADMIN_USERNAME | admin | Admin username | yes | 22 | | NOVOSGA_ADMIN_PASSWORD | 123456 | Admin password | yes | 23 | | NOVOSGA_ADMIN_FIRSTNAME | Administrator | Administrator first name | yes | 24 | | NOVOSGA_ADMIN_LASTNAME | Global | Administrador last name | yes | 25 | | NOVOSGA_UNITY_NAME | My Unity | Unity name | yes | 26 | | NOVOSGA_UNITY_CODE | U01 | Unity code | yes | 27 | | NOVOSGA_NOPRIORITY_DESCRIPTION | Normal service | Non-Priority service description | yes | 28 | | NOVOSGA_PRIORITY_NAME | Priority | Priority service name | yes | 29 | | NOVOSGA_PRIORITY_DESCRIPTION | Priority service | Priority service description | yes | 30 | | NOVOSGA_PLACE_NAME | Box | Place name | yes | 31 | | TZ | UTC | Timezone | yes | 32 | 33 | ## Documentation 34 | 35 | https://novosga.org/docs/#/2.1/install-docker 36 | -------------------------------------------------------------------------------- /novosga-2.1/apache2/htaccess: -------------------------------------------------------------------------------- 1 | Options -MultiViews 2 | RewriteEngine On 3 | RewriteCond %{REQUEST_FILENAME} !-f 4 | RewriteRule ^(.*)$ index.php [QSA,L] 5 | PassEnv APP_ENV 6 | PassEnv DATABASE_URL 7 | PassEnv DATABASE_PASS 8 | PassEnv TRUSTED_PROXIES 9 | PassEnv TRUSTED_HOSTS 10 | -------------------------------------------------------------------------------- /novosga-2.1/crontab/cron: -------------------------------------------------------------------------------- 1 | # m h dom mon dow command 2 | 0 1 * * * root /usr/local/bin/php /var/www/html/bin/console novosga:reset > /var/log/novosga-reset.log 2>&1 3 | -------------------------------------------------------------------------------- /novosga-2.1/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Starting pre-flight check..." 3 | 4 | echo -n "Database url: " 5 | if [ -z "$DATABASE_URL" ]; then 6 | echo "\nYou need to tell me where the database is and how to connect to it by setting DATABASE_URL environment variable" 7 | echo "e.g.: Using the flag -e DATABASE_URL='mysql://user:pass@127.0.0.1:3306/dbname?charset=utf8mb4&serverVersion=5.7' at docker container run" 8 | exit 1 9 | fi 10 | echo "Ok" 11 | 12 | bin/console cache:clear --no-debug --no-warmup 13 | bin/console cache:warmup 14 | 15 | # we need to wait until the database is up and accepting connections 16 | until bin/console -q doctrine:query:sql "select version()" > /dev/null 2>&1; do 17 | echo "Waiting for database..."; 18 | sleep 5; 19 | done 20 | 21 | echo "Database is up, configuring schema" 22 | 23 | set -xe 24 | 25 | # Copy env vars to environment file (for cron usage) 26 | printenv >> /etc/environment 27 | 28 | # Install/Updates the database schema 29 | /var/www/html/bin/console novosga:install 30 | 31 | echo "Setup done! Starting apache" 32 | exec /usr/bin/supervisord -n 33 | -------------------------------------------------------------------------------- /novosga-2.1/supervisor/apache2.conf: -------------------------------------------------------------------------------- 1 | [program:apache2] 2 | command = apache2-foreground 3 | stdout_logfile = /var/log/novosga-apache2.log 4 | stderr_logfile = /var/log/novosga-apache2-error.log 5 | -------------------------------------------------------------------------------- /novosga-2.1/supervisor/cron.conf: -------------------------------------------------------------------------------- 1 | [program:cron] 2 | command = cron -f 3 | 4 | -------------------------------------------------------------------------------- /novosga-2.2-standalone/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM novosga/novosga:2.2 2 | 3 | #Set the default parameters 4 | ENV APP_ENV=prod \ 5 | LANGUAGE=pt_BR \ 6 | NOVOSGA_ADMIN_USERNAME="admin" \ 7 | NOVOSGA_ADMIN_PASSWORD="123456" \ 8 | NOVOSGA_ADMIN_FIRSTNAME="Administrador" \ 9 | NOVOSGA_ADMIN_LASTNAME="Global" \ 10 | NOVOSGA_UNITY_NAME="Minha Unidade" \ 11 | NOVOSGA_UNITY_CODE="U01" \ 12 | NOVOSGA_NOPRIORITY_NAME="Normal" \ 13 | NOVOSGA_NOPRIORITY_DESCRIPTION="Serviço normal" \ 14 | NOVOSGA_PRIORITY_NAME="Prioridade" \ 15 | NOVOSGA_PRIORITY_DESCRIPTION="Serviço prioritário" \ 16 | NOVOSGA_PLACE_NAME="Guichê" 17 | 18 | USER root 19 | 20 | # https://github.com/aptible/supercronic/releases/tag/v0.2.33 21 | ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.33/supercronic-linux-amd64 \ 22 | SUPERCRONIC_SHA1SUM=71b0d58cc53f6bd72cf2f293e09e294b79c666d8 \ 23 | SUPERCRONIC=supercronic-linux-amd64 24 | 25 | RUN curl -fsSLO "$SUPERCRONIC_URL" \ 26 | && echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \ 27 | && chmod +x "$SUPERCRONIC" \ 28 | && mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \ 29 | && ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic 30 | 31 | COPY start.sh /usr/local/bin 32 | COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf 33 | COPY config/crontab /etc/crontab 34 | 35 | USER nobody 36 | 37 | CMD ["start.sh"] 38 | -------------------------------------------------------------------------------- /novosga-2.2-standalone/README.md: -------------------------------------------------------------------------------- 1 | # NovoSGA 2.2 2 | 3 | ## Docker image milestones 4 | 5 | - [x] Pre-flight check 6 | - [x] Auto setup 7 | - [x] Daily ticket reset at 1am 8 | - [ ] docker secrets support 9 | 10 | ## How to use 11 | 12 | The container will check if the required settings are set and will start the database setup automatically. 13 | You can set the system as you like with environment variables (using docker-compose.yml or `-e` flags at `docker container run`) 14 | 15 | ### Settings (environment variables) 16 | 17 | | Option | Default setting | Description | Optional? | 18 | | ------------------------------ | ----------------- | -------------------------------- | :-------: | 19 | | APP_ENV | prod | Environment running the app | yes | 20 | | DATABASE_URL | *blank* | Database connection string | ***no*** | 21 | | NOVOSGA_ADMIN_USERNAME | admin | Admin username | yes | 22 | | NOVOSGA_ADMIN_PASSWORD | 123456 | Admin password | yes | 23 | | NOVOSGA_ADMIN_FIRSTNAME | Administrator | Administrator first name | yes | 24 | | NOVOSGA_ADMIN_LASTNAME | Global | Administrador last name | yes | 25 | | NOVOSGA_UNITY_NAME | My Unity | Unity name | yes | 26 | | NOVOSGA_UNITY_CODE | U01 | Unity code | yes | 27 | | NOVOSGA_NOPRIORITY_DESCRIPTION | Normal service | Non-Priority service description | yes | 28 | | NOVOSGA_PRIORITY_NAME | Priority | Priority service name | yes | 29 | | NOVOSGA_PRIORITY_DESCRIPTION | Priority service | Priority service description | yes | 30 | | NOVOSGA_PLACE_NAME | Box | Place name | yes | 31 | | TZ | UTC | Timezone | yes | 32 | -------------------------------------------------------------------------------- /novosga-2.2-standalone/config/crontab: -------------------------------------------------------------------------------- 1 | # m h dom mon dow command 2 | 0 1 * * * /var/www/html/bin/console novosga:reset 3 | -------------------------------------------------------------------------------- /novosga-2.2-standalone/config/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | logfile=/dev/null 4 | logfile_maxbytes=0 5 | pidfile=/run/supervisord.pid 6 | 7 | [program:php-fpm] 8 | command=php-fpm82 -F 9 | stdout_logfile=/dev/stdout 10 | stdout_logfile_maxbytes=0 11 | stderr_logfile=/dev/stderr 12 | stderr_logfile_maxbytes=0 13 | autorestart=false 14 | startretries=0 15 | 16 | [program:nginx] 17 | command=nginx -g 'daemon off;' 18 | stdout_logfile=/dev/stdout 19 | stdout_logfile_maxbytes=0 20 | stderr_logfile=/dev/stderr 21 | stderr_logfile_maxbytes=0 22 | autorestart=false 23 | startretries=0 24 | 25 | [program:supercronic] 26 | command=supercronic /etc/crontab 27 | stdout_logfile=/dev/stdout 28 | stdout_logfile_maxbytes=0 29 | stderr_logfile=/dev/stderr 30 | stderr_logfile_maxbytes=0 31 | autorestart=false 32 | startretries=0 33 | -------------------------------------------------------------------------------- /novosga-2.2-standalone/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Starting pre-flight check..." 3 | 4 | echo -n "Database url: " 5 | if [ -z "$DATABASE_URL" ]; then 6 | echo "\nYou need to tell me where the database is and how to connect to it by setting DATABASE_URL environment variable" 7 | echo "e.g.: Using the flag -e DATABASE_URL='mysql://user:pass@127.0.0.1:3306/dbname?charset=utf8mb4&serverVersion=5.7' at docker container run" 8 | exit 1 9 | fi 10 | echo "Ok" 11 | 12 | bin/console cache:clear --no-debug --no-warmup 13 | bin/console cache:warmup 14 | 15 | # we need to wait until the database is up and accepting connections 16 | until bin/console -q doctrine:query:sql "select version()" > /dev/null 2>&1; do 17 | echo "Waiting for database..."; 18 | sleep 5; 19 | done 20 | 21 | echo "Database is up, configuring schema" 22 | 23 | set -xe 24 | 25 | # Install/Updates the database schema 26 | bin/console novosga:install 27 | 28 | echo "Setup done! Starting application" 29 | exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf 30 | -------------------------------------------------------------------------------- /php-baseimage/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.1-apache 2 | 3 | RUN set -xe \ 4 | && apt-get update \ 5 | && apt-get install -y \ 6 | cron \ 7 | git \ 8 | libcurl3-dev \ 9 | libicu-dev \ 10 | libmcrypt-dev \ 11 | libjpeg62-turbo-dev \ 12 | libpng-dev \ 13 | libfreetype6-dev \ 14 | libgd2-xpm-dev \ 15 | libxml2-dev \ 16 | zlib1g-dev \ 17 | supervisor \ 18 | && docker-php-ext-configure \ 19 | gd \ 20 | --enable-gd-native-ttf \ 21 | --with-freetype \ 22 | --with-freetype-dir=/usr/include/freetype2 \ 23 | --with-png-dir=/usr/include \ 24 | --with-jpeg-dir=/usr/include \ 25 | && docker-php-ext-install \ 26 | curl \ 27 | gd \ 28 | intl \ 29 | pcntl \ 30 | pdo \ 31 | pdo_mysql \ 32 | xml \ 33 | zip \ 34 | && apt-get remove -y --purge \ 35 | postgresql-server-dev-all \ 36 | libicu-dev \ 37 | libxml2-dev \ 38 | zlib1g-dev \ 39 | && apt-get clean \ 40 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 41 | && a2enmod rewrite env \ 42 | && echo 'session.save_path = "/tmp"' > /usr/local/etc/php/conf.d/sessionsavepath.ini \ 43 | && echo 'date.timezone = ${TZ}' > /usr/local/etc/php/conf.d/datetimezone.ini 44 | -------------------------------------------------------------------------------- /php-baseimage/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build --no-cache --rm -t novosga/php-baseimage . 4 | --------------------------------------------------------------------------------