Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ntxbot committed Sep 8, 2016
0 parents commit b318807
Show file tree
Hide file tree
Showing 5,902 changed files with 394,439 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
README.md
.git
*/.git
*/node_modules/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
hashs.txt
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ntxcode/ubuntu-base:14.04
MAINTAINER Nathan Ribeiro, ntxdev <[email protected]>

# Install nginx
RUN \
apt-get update -yq && DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends nginx && \
mkdir -p /var/www

# Copy application builds to their expected location
COPY ./zup-landingpage /var/www/zup-landing
COPY ./zup-painel /var/www/zup-painel
COPY ./zup-web-angular /var/www/zup-web-cidadao

COPY ./entrypoint.sh /

COPY ./nginx.conf /etc/nginx/nginx.conf
RUN rm /etc/nginx/sites-enabled/default
RUN chown -R nobody. /var/www

ENTRYPOINT ["/entrypoint.sh"]

CMD ["nginx"]
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ZUP Web

Este repositório contém os arquivos necessários para construir uma imagem Docker contendo o Painel, Aplicativo Web
Cidadão e Landing Page do projeto ZUP. Para projetos que utilizem dois ou mais desses componentes, esse repositório pode
ser utilizado para facilitar o processo de deploy.

## Build da imagem

Primeiramente, atualize as pastas `zup-landingpage`, `zup-painel` e `zup-web-angular` com a build de produção (pasta `dist`)
dos respectivos componentes. Após isso basta executar o seguinte comando:

```
docker build -t zup-web:latest .
```

Isso fará com que uma imagem `zup-web` com a tag `latest` seja gerada.


## Configuração e execução

Crie um arquivo `web.env` em uma localização de sua preferência. Dentro desse arquivo, coloque em cada linha qualquer uma das
variáveis oferecidas pelo Painel, Cidadão Web e Landing Page. Após isso, basta rodar a imagem com o seguinte comando:

```
docker run -d --name zup-web --env-file /algum/caminho/web.env -p 80:80 zup-web:latest
```

O servidor irá servir os arquivos na porta 80 do host do Docker.
118 changes: 118 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env bash
set -e
set -o pipefail

blow_up() {
echo "Missing required enviroment variable '$1'. Please, take a look at the manual." >&2
exit 1
}
[ "$API_URL" ] || blow_up 'API_URL'
[ "$MAP_LAT" ] || blow_up 'MAP_LAT'
[ "$MAP_LNG" ] || blow_up 'MAP_LNG'
[ "$MAP_ZOOM" ] || blow_up 'MAP_ZOOM'

if [ "$DISABLE_PANEL" = true ] ; then
rm -rf /var/www/zup-painel
else
sed -i -E "s@(apiEndpoint:')([^']*)?(')@\1$API_URL\3@g" /var/www/zup-painel/config/main.constants.js
sed -i -E "s@(mapLat:')([^']*)?(')@\1$MAP_LAT\3@g" /var/www/zup-painel/config/main.constants.js
sed -i -E "s@(mapLng:')([^']*)?(')@\1$MAP_LNG\3@g" /var/www/zup-painel/config/main.constants.js
sed -i -E "s@(mapZoom:')([^']*)?(')@\1$MAP_ZOOM\3@g" /var/www/zup-painel/config/main.constants.js
sed -i -E "s@(logoImgUrl:')([^']*)?(')@\1$LOGO_IMG_URL\3@g" /var/www/zup-painel/config/main.constants.js
sed -i -E "s@(theme:')([^']*)?(')@\1$THEME\3@g" /var/www/zup-painel/config/main.constants.js

sed -i "s@SENTRY_DSN@$SENTRY_DSN@g" /var/www/zup-painel/index.html
sed -i "s@GOOGLE_ANALYTICS_KEY@$GOOGLE_ANALYTICS_KEY@g" /var/www/zup-painel/index.html
sed -i "s@PAGE_TITLE@$PANEL_PAGE_TITLE@g" /var/www/zup-painel/index.html

[ -d /painel/images ] && cp -R /painel/images/*.* /var/www/zup-painel/assets/images
fi

if [ "$DISABLE_WEB_APP" = true ] ; then
echo "Web citizen application will not be available."
rm -rf /var/www/zup-web-cidadao/**/*
[ "$DISABLE_PANEL" != true ] && echo '<html><head><meta http-equiv="refresh" content="0;URL=/painel" /></head></html>' > /var/www/zup-web-cidadao/index.html
else
sed -i -E "s@(apiEndpoint:')([^']*)?(')@\1$API_URL\3@g" /var/www/zup-web-cidadao/scripts/constants.js
sed -i -E "s@(mapLat:')([^']*)?(')@\1$MAP_LAT\3@g" /var/www/zup-web-cidadao/scripts/constants.js
sed -i -E "s@(mapLng:')([^']*)?(')@\1$MAP_LNG\3@g" /var/www/zup-web-cidadao/scripts/constants.js
sed -i -E "s@(mapZoom:')([^']*)?(')@\1$MAP_ZOOM\3@g" /var/www/zup-web-cidadao/scripts/constants.js

sed -i "s@GOOGLE_ANALYTICS_KEY@$GOOGLE_ANALYTICS_KEY@g" /var/www/zup-web-cidadao/index.html

[ -d /web/images ] && cp -R /web/images/*.* /var/www/zup-web-cidadao/images

if [ -z "$PAGE_TITLE" ]; then
sed -i "s@PAGE_TITLE@ZUP Web@g" /var/www/zup-web-cidadao/index.html
else
sed -i "s@PAGE_TITLE@$PAGE_TITLE@g" /var/www/zup-web-cidadao/index.html
fi

[ -f /web/terms.html ] && TERMS_AND_CONDITIONS_HTML=`cat /web/terms.html`

if [ -z "$TERMS_AND_CONDITIONS_HTML" ]; then
sed -i "s@HAS_TERMS_AND_CONDITIONS@none@g" /var/www/zup-web-cidadao/styles/*.main.css
else
perl -i -pe "s@TERMS_AND_CONDITIONS_HTML@$TERMS_AND_CONDITIONS_HTML@g" /var/www/zup-web-cidadao/index.html
perl -i -pe "s@TERMS_AND_CONDITIONS_HTML@$TERMS_AND_CONDITIONS_HTML@g" /var/www/zup-web-cidadao/views/modal_terms_of_use.html
sed -i "s@HAS_TERMS_AND_CONDITIONS@block@g" /var/www/zup-web-cidadao/styles/*.main.css
fi
fi

[ "$DEFAULT_CITY" != "" ] && CITY_NAME=$DEFAULT_CITY
if [ "$DISABLE_LANDING_PAGE" = true ] || [ -z "$CITY_NAME" ] ; then
echo "Landing page will not be available."
rm -rf /var/www/zup-landing/**/*
[ "$DISABLE_PANEL" != true ] && echo '<html><head><meta http-equiv="refresh" content="0;URL=/painel" /></head></html>' > /var/www/zup-landing/index.html
else
sed -i "s@CITY_NAME@$CITY_NAME@g" /var/www/zup-landing/index.html

[ -d /landing-page/images ] && cp -R /landing-page/images/*.* /var/www/zup-landing/images

if [ -z "$PAGE_TITLE" ]; then
sed -i "s@PAGE_TITLE@ZUP@g" /var/www/zup-landing/index.html
else
sed -i "s@PAGE_TITLE@$PAGE_TITLE@g" /var/www/zup-landing/index.html
fi

if [ -z "$APPLICATION_NAME" ]; then
sed -i "s@APPLICATION_NAME@ZUP@g" /var/www/zup-landing/index.html
else
sed -i "s@APPLICATION_NAME@$APPLICATION_NAME@g" /var/www/zup-landing/index.html
fi

sed -i "s@API_URL@$API_URL@g" /var/www/zup-landing/scripts/main.js
if [ -z "$IOS_APP_LINK" ]; then
sed -i "s@HAS_IOS_APP_LINK@none@g" /var/www/zup-landing/styles/main.css
else
sed -i "s@IOS_APP_LINK@$IOS_APP_LINK@g" /var/www/zup-landing/index.html
sed -i "s@HAS_IOS_APP_LINK@block@g" /var/www/zup-landing/styles/main.css
fi

if [ -z "$ANDROID_APP_LINK" ]; then
sed -i "s@HAS_ANDROID_APP_LINK@none@g" /var/www/zup-landing/styles/main.css
else
sed -i "s@ANDROID_APP_LINK@$ANDROID_APP_LINK@g" /var/www/zup-landing/index.html
sed -i "s@HAS_ANDROID_APP_LINK@block@g" /var/www/zup-landing/styles/main.css
fi

if [ -z "$WEB_APP_LINK" ]; then
sed -i "s@HAS_WEB_APP_LINK@none@g" /var/www/zup-landing/styles/main.css
else
sed -i "s@WEB_APP_LINK@$WEB_APP_LINK@g" /var/www/zup-landing/index.html
sed -i "s@HAS_WEB_APP_LINK@block@g" /var/www/zup-landing/styles/main.css
fi

[ -f /landing-page/terms.html ] && TERMS_AND_CONDITIONS_HTML=`cat /landing-page/terms.html`

if [ -z "$TERMS_AND_CONDITIONS_HTML" ]; then
sed -i "s@HAS_TERMS_AND_CONDITIONS@none@g" /var/www/zup-landing/styles/main.css
else
perl -i -pe "s@TERMS_AND_CONDITIONS_HTML@$TERMS_AND_CONDITIONS_HTML@g" /var/www/zup-landing/index.html
sed -i "s@HAS_TERMS_AND_CONDITIONS@block@g" /var/www/zup-landing/styles/main.css
fi
fi

echo "ZUP-WEB is running."

exec "$@"
61 changes: 61 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
worker_processes 5; ## Default: 1
error_log /dev/stdout;
worker_rlimit_nofile 8192;
daemon off;

events {
worker_connections 4096; ## Default: 1024
}

http {
include /etc/nginx/mime.types;

gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "msie6";

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

default_type application/octet-stream;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

rewrite ^([^\?#]*/)([^\?#\./]+)([\?#].*)?$ $scheme://$http_host$uri/ permanent;

root /var/www/zup-landing;
index index.html index.htm;

location /landing {
alias /var/www/zup-landing;
}

location /painel {
alias /var/www/zup-painel;
}

location /web {
alias /var/www/zup-web-cidadao;
}
}
}
Loading

0 comments on commit b318807

Please sign in to comment.