Skip to content

Commit

Permalink
informação da versão na interface, label nas imagens, makefile improv…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
jfunez committed Dec 20, 2016
1 parent 44a439d commit eedd1dd
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ language: python

env:
global:
- COMMIT=${TRAVIS_COMMIT::8}
- COMMIT=${TRAVIS_COMMIT::8}
- OPAC_BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
- OPAC_VCS_REF=$COMMIT
- OPAC_WEBAPP_VERSION=`cat VERSION`

services:
- docker
Expand All @@ -31,4 +34,4 @@ after_success:
fi

notifications:
slack: scielo:6YcYDMh1STDOQT8H7umVuD0R
slack: scielo:6YcYDMh1STDOQT8H7umVuD0R
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
FROM python:3.5-alpine
ENV PYTHONUNBUFFERED 1

# Build-time metadata as defined at http://label-schema.org
ARG OPAC_BUILD_DATE
ARG OPAC_VCS_REF
ARG OPAC_WEBAPP_VERSION

ENV OPAC_BUILD_DATE ${OPAC_BUILD_DATE}
ENV OPAC_VCS_REF ${OPAC_VCS_REF}
ENV OPAC_WEBAPP_VERSION ${OPAC_WEBAPP_VERSION}

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="OPAC WebApp - development build" \
org.label-schema.description="OPAC WebApp main app" \
org.label-schema.url="https://github.com/scieloorg/opac/" \
org.label-schema.vcs-ref=$OPAC_VCS_REF \
org.label-schema.vcs-url="https://github.com/scieloorg/opac/" \
org.label-schema.vendor="SciELO" \
org.label-schema.version=$OPAC_WEBAPP_VERSION \
org.label-schema.schema-version="1.0"

RUN apk --update add --no-cache \
git gcc build-base zlib-dev jpeg-dev

Expand All @@ -12,6 +31,8 @@ RUN pip --no-cache-dir install -r requirements.txt && \
pip --no-cache-dir install -r /app/requirements.dev.txt

RUN make compile_messages
RUN chown -R nobody:nogroup /app
USER nobody
EXPOSE 8000

CMD gunicorn --workers 3 --bind 0.0.0.0:8000 manager:app --chdir=/app/opac --log-level INFO
21 changes: 20 additions & 1 deletion Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
FROM python:3.5-alpine
ENV PYTHONUNBUFFERED 1

# Build-time metadata as defined at http://label-schema.org
ARG OPAC_BUILD_DATE
ARG OPAC_VCS_REF
ARG OPAC_WEBAPP_VERSION

ENV OPAC_BUILD_DATE ${OPAC_BUILD_DATE}
ENV OPAC_VCS_REF ${OPAC_VCS_REF}
ENV OPAC_WEBAPP_VERSION ${OPAC_WEBAPP_VERSION}

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="OPAC WebApp - development build" \
org.label-schema.description="OPAC WebApp main app" \
org.label-schema.url="https://github.com/scieloorg/opac/" \
org.label-schema.vcs-ref=$OPAC_VCS_REF \
org.label-schema.vcs-url="https://github.com/scieloorg/opac/" \
org.label-schema.vendor="SciELO" \
org.label-schema.version=$OPAC_WEBAPP_VERSION \
org.label-schema.schema-version="1.0"

RUN apk --update add --no-cache \
git gcc build-base zlib-dev jpeg-dev

Expand All @@ -10,7 +29,7 @@ COPY ./requirements.dev.txt /app/requirements.dev.txt

RUN pip --no-cache-dir install -r /app/requirements.txt && \
pip --no-cache-dir install -r /app/requirements.dev.txt

RUN chown -R nobody:nogroup /app
USER nobody

EXPOSE 8000
Expand Down
35 changes: 30 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
default: test

#########
## deps #
#########
update_requirements:
pip install --upgrade -r requirements.txt
COMPOSE_FILE_DEV = docker-compose-dev.yml
OPAC_BUILD_DATE= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
OPAC_VCS_REF= $(shell git rev-parse --short HEAD)
OPAC_WEBAPP_VERSION=$(strip $(shell cat VERSION))

############################################
## atalhos docker-compose desenvolvimento ##
############################################

dev_compose_build:
docker-compose -f $(COMPOSE_FILE_DEV) build

dev_compose_up:
docker-compose -f $(COMPOSE_FILE_DEV) up -d

dev_compose_logs:
docker-compose -f $(COMPOSE_FILE_DEV) logs -f

dev_compose_stop:
docker-compose -f $(COMPOSE_FILE_DEV) stop

dev_compose_ps:
docker-compose -f $(COMPOSE_FILE_DEV) ps

dev_compose_rm:
docker-compose -f $(COMPOSE_FILE_DEV) rm -f

dev_compose_exec_shell_webapp:
docker-compose -f $(COMPOSE_FILE_DEV) exec opac_webapp sh

#########
## i18n #
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12
7 changes: 6 additions & 1 deletion docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ services:
- /etc/localtime:/etc/localtime:ro

opac_webapp:
build: .
build:
context: .
args:
- OPAC_BUILD_DATE=${OPAC_BUILD_DATE} # export OPAC_BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
- OPAC_VCS_REF=${OPAC_VCS_REF} # export OPAC_VCS_REF=`git rev-parse --short HEAD`
- OPAC_WEBAPP_VERSION=${OPAC_WEBAPP_VERSION} # export OPAC_WEBAPP_VERSION="v0.1.0-dev"
user: nobody
restart: always
hostname: opac_webapp
Expand Down
4 changes: 4 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ services:
build:
context: .
dockerfile: ./Dockerfile-dev
args:
- OPAC_BUILD_DATE=${OPAC_BUILD_DATE} # export OPAC_BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
- OPAC_VCS_REF=${OPAC_VCS_REF} # export OPAC_VCS_REF=`git rev-parse --short HEAD`
- OPAC_WEBAPP_VERSION=${OPAC_WEBAPP_VERSION} # export OPAC_WEBAPP_VERSION="v0.1.0-dev"
command: gunicorn --workers 3 --bind 0.0.0.0:8000 manager:app --chdir=/app/opac --reload --timeout 1000 --log-level DEBUG
user: nobody
restart: always
Expand Down
9 changes: 9 additions & 0 deletions opac/webapp/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
- OPAC_USE_SENTRY: ativa/desativa a integarção com Sentry, se sim definir como: 'True' (default: 'False')
- OPAC_SENTRY_DSN: (string) DSN definido pelo sentry para este projeto. Utilizado só se OPAC_USE_SENTRY == True (default: '')
- docker build args (ignorar warnings na construção de imagem para desenvolvimento)
- OPAC_BUILD_DATE: data de build. definida em tempo de construção da imagem.
- OPAC_VCS_REF: commit do código. definida pelo travis em tempo de construção da imagem.
- OPAC_WEBAPP_VERSION: 'versão do OPAC WEBAPP'. definida pelo travis em tempo de construção da imagem.
"""

PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
Expand Down Expand Up @@ -263,3 +267,8 @@
# Sentry settings:
USE_SENTRY = os.environ.get('OPAC_USE_SENTRY', 'False') == 'True'
SENTRY_DSN = os.environ.get('OPAC_SENTRY_DSN', '')

# build args:
BUILD_DATE = os.environ.get('OPAC_BUILD_DATE', None)
VCS_REF = os.environ.get('OPAC_VCS_REF', None)
WEBAPP_VERSION = os.environ.get('OPAC_WEBAPP_VERSION', None)
12 changes: 11 additions & 1 deletion opac/webapp/templates/admin/opac_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@
</div>
</div>
</div>

{% if config.BUILD_DATE or config.VCS_REF or config.WEBAPP_VERSION %}
<div class="container">
<div class="text-center">
<small>
{% if config.BUILD_DATE %}{{config.BUILD_DATE}} | {% endif %}
{% if config.VCS_REF %} {{config.VCS_REF}} | {% endif %}
{% if config.WEBAPP_VERSION %} {{ config.WEBAPP_VERSION }}{% endif %}
</small>
</div>
</div>
{% endif %}
<script src="{{ url_for('static', filename='js/vendor/jquery.popupwindows.js') }}"> </script>
<script src="{{ url_for('static', filename='js/admin/common.js') }}"> </script>

Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

long_description = open('README.rst', 'r').read()

with open('VERSION') as version_file:
version = version_file.read()
version = version.strip()

install_requirements = [
'Flask>=0.10.1',
'mongoengine>=0.10.0',
Expand Down Expand Up @@ -35,7 +39,7 @@

setup(
name='opac',
version='0.11-dev',
version=version,
long_description=long_description,
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit eedd1dd

Please sign in to comment.