Skip to content

Commit

Permalink
Merge pull request #19 from filiperochalopes/feature/testing-env
Browse files Browse the repository at this point in the history
deploy training version and create update script
  • Loading branch information
filiperochalopes authored Dec 21, 2024
2 parents c76bf96 + c87a73a commit a98fe96
Show file tree
Hide file tree
Showing 42 changed files with 974 additions and 750 deletions.
23 changes: 0 additions & 23 deletions .devcontainer/Dockerfile

This file was deleted.

33 changes: 0 additions & 33 deletions .devcontainer/devcontainer.json

This file was deleted.

44 changes: 0 additions & 44 deletions .devcontainer/docker-compose.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .env

This file was deleted.

5 changes: 5 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Timezone da aplicação que definirá o horário do sistema
TZ='America/Bahia'

# Configurações de HTTPS
HTTPS_DOMAIN='exemplo.gov.br'
19 changes: 15 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# Configurações de banco de dados
POSTGRES_DB='esus'
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='esus'
POSTGRESQL_PORT=54351
APP_PORT=88
PGWEB_PORT=8099
POSTGRES_PASS='pass'
POSTGRES_HOST='host.docker.internal'
POSTGRES_PORT=5432

# Arquivo específico de instalação para determinar versão a ser instalada, caso não preenchido o script buscará a última versão disponível na página
FILENAME="https://arquivos.esusab.ufsc.br/PEC/e925378f33a611e7/5.3.19/eSUS-AB-PEC-5.3.19-Linux64.jar"

# Porta da aplicação de desenvolvimento
APP_PORT=8081

# Timezone da aplicação que definirá o horário do sistema
TZ='America/Bahia'

# Configurações de HTTPS
HTTPS_DOMAIN='exemplo.gov.br'
10 changes: 0 additions & 10 deletions .env.external-db.example

This file was deleted.

24 changes: 14 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
data
*.jar
__pycache__
*.pyc
*.backup
*.class
*.java
*.deb
*.log
*.sql
*.gz
data/
__pycache__
.webassets-cache
.vscode/
.env
.env.external-db
client_secret_*.json
credentials.json
token.json
venv
*.class
*.java
pec.log
*.deb
*.log
docker-compose.npm.yml
*.sql
.env.external-db
decompiled-java/
certificates/
*entrypoint/
nginx/
opt-esus/
esus-*/
certificates/
nginx/
jar-*/
80 changes: 57 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@ FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Instalando fontes que o PEC utiliza para impressão: ttf-mscorefonts-installer (limitação de versão 5.3.19-5.3.21)
# fontconfig para reinstalar fontes após modificação
# coreutils para reconhecer arquitetura x64
RUN apt-get update && apt-get install -y \
locales \
&& locale-gen "pt_BR.UTF-8" \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& apt-get install -y \
wget apt-utils gnupg2 software-properties-common file libfreetype6 ntp
coreutils wget apt-utils gnupg2 software-properties-common file libfreetype6 ntp ttf-mscorefonts-installer fontconfig

# Instalando java 8, pre-requisitos para instalação do sistema PEC
RUN wget -O- https://apt.corretto.aws/corretto.key | apt-key add -
RUN add-apt-repository 'deb https://apt.corretto.aws stable main'
RUN apt-get update && apt-get install -y java-1.8.0-amazon-corretto-jdk
RUN fc-cache -fv

RUN chmod -R 777 /usr/share/fonts/truetype/msttcorefonts

# Adicionar chave pública diretamente da URL correta
RUN wget -O - https://apt.corretto.aws/corretto.key | gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg

# Adicionar o repositório do Corretto, vinculando à chave
RUN echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" | tee /etc/apt/sources.list.d/corretto.list

# Atualizar repositórios e instalar o Corretto 17 LTS
RUN apt-get update && apt-get install -y java-17-amazon-corretto-jdk

# Enable all repositories
RUN sed -i 's/# deb/deb/g' /etc/apt/sources.list
Expand All @@ -24,33 +35,56 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /usr/share/doc/* /usr/share/man/* /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Instalar cliente PostgreSQL
RUN apt-get update && apt-get install -y postgresql-client

# Substituir o comando `ps` para burlar a verificação de systemd
RUN mv /bin/ps /bin/ps.original && \
echo '#!/bin/sh' > /bin/ps && \
echo 'if [ "$1" = "--no-headers" ] && [ "$2" = "-o" ] && [ "$3" = "comm" ] && [ "$4" = "1" ]; then' >> /bin/ps && \
echo ' echo "systemd (simulated: ps $@)"' >> /bin/ps && \
echo 'else' >> /bin/ps && \
echo ' /bin/ps.original "$@"' >> /bin/ps && \
echo 'fi' >> /bin/ps && \
chmod +x /bin/ps

RUN echo '#!/bin/sh' > /bin/systemctl && \
echo 'echo "Simulated systemctl command: $0 $@"' >> /bin/systemctl && \
echo 'case "$1" in' >> /bin/systemctl && \
echo ' start|stop|restart|status) exit 0 ;;' >> /bin/systemctl && \
echo ' *) echo "Simulated systemctl: $@"; exit 0 ;;' >> /bin/systemctl && \
echo 'esac' >> /bin/systemctl && \
chmod +x /bin/systemctl

ARG JAR_FILENAME
ARG HTTPS_DOMAIN
ARG DB_URL
ARG POSTGRES_PASS
ARG POSTGRES_USER
ARG TRAINING
ARG POSTGRES_USERNAME
ARG POSTGRES_PASSWORD
ARG POSTGRES_DATABASE
ARG TZ
ARG DUMPFILE

# Promovendo ARGS para ENV para uso no install.sh que roda dentro do entrypoint.sh e precisa dessas variáveis
ENV JAR_FILENAME=${JAR_FILENAME}
ENV DUMPFILE=${DUMPFILE}
ENV TRAINING=${TRAINING}
ENV POSTGRES_USERNAME=${POSTGRES_USERNAME}
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ENV POSTGRES_DATABASE=${POSTGRES_DATABASE}
ENV TZ=${TZ}

RUN export JAR_FILENAME=${JAR_FILENAME}
ENV DB_URL=${DB_URL}
ENV POSTGRES_PASS=${POSTGRES_PASS}
ENV POSTGRES_USER=${POSTGRES_USER}
ENV HTTPS_DOMAIN=${HTTPS_DOMAIN}

# criando diretórios para uso posterior
RUN mkdir -p /opt/e-SUS/webserver/chaves
RUN mkdir /backups
RUN mkdir -p /var/www/html
WORKDIR /var/www/html

COPY ./${JAR_FILENAME} ${JAR_FILENAME}
COPY ./${DUMPFILE} ${DUMPFILE}
COPY ./install.sh install.sh
COPY ./run.sh run.sh
COPY ./install.sh .

# Copiando arquivos de backup
COPY *.sql /backups
COPY *.backup /backups

RUN chmod +x /var/www/html/install.sh
RUN chmod +x /var/www/html/run.sh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

CMD ["/bin/bash", "/var/www/html/run.sh"]
ENTRYPOINT ["/entrypoint.sh"]
30 changes: 20 additions & 10 deletions Dockerfile.external-db
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

# Instalando fontes que o PEC utiliza para impressão
RUN apt-get update && apt-get install -y \
locales \
&& locale-gen "pt_BR.UTF-8" \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& apt-get install -y \
wget apt-utils gnupg2 software-properties-common file libfreetype6 ntp
wget apt-utils gnupg2 software-properties-common file libfreetype6 ntp ttf-mscorefonts-installer fontconfig

RUN fc-cache -fv

RUN chmod -R 777 /usr/share/fonts/truetype/msttcorefonts

# Adicionar chave pública diretamente da URL correta
RUN wget -O - https://apt.corretto.aws/corretto.key | gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg
Expand All @@ -31,27 +36,32 @@ RUN apt-get update && \
ARG JAR_FILENAME
ARG HTTPS_DOMAIN
ARG DB_URL
ARG DB_PASS
ARG DB_USER
ARG DUMPFILE
ARG POSTGRES_PASS
ARG POSTGRES_USER

# Promovendo ARGS para ENV
# Promovendo ARGS para ENV para uso no install.sh que roda dentro do entrypoint
ENV JAR_FILENAME=${JAR_FILENAME}
ENV DB_URL=${DB_URL}
ENV DB_PASS=${DB_PASS}
ENV DB_USER=${DB_USER}
ENV POSTGRES_PASS=${POSTGRES_PASS}
ENV POSTGRES_USER=${POSTGRES_USER}
ENV HTTPS_DOMAIN=${HTTPS_DOMAIN}

# criando diretórios para uso posterior
RUN mkdir -p /opt/e-SUS/webserver/chaves
RUN mkdir /backups
RUN mkdir -p /var/www/html
WORKDIR /var/www/html

# ATENÇÃO: Esse é um Dockerfile de instalação e não de atualização
# Removendo arquivos de configuração anteriores, para instalar do zero.
RUN if [ -f /etc/pec.config ]; then rm /etc/pec.config; fi

COPY ./${JAR_FILENAME} ${JAR_FILENAME}
COPY ./run-java.sh .
COPY ./install.sh .

# Copiando arquivos de backup
COPY *.sql .
COPY *.backup .
COPY *.sql /backups
COPY *.backup /backups

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
Expand Down
Loading

0 comments on commit a98fe96

Please sign in to comment.