Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin commit in repos #35

Open
wants to merge 4 commits into
base: 12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/dev_token.py
__pycache__/
*.py[cod]
*$py.class
141 changes: 141 additions & 0 deletions Dockerfile.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# DOCKER para odoo 12 de Odoo Community Backports
FROM debian:stretch
MAINTAINER Rubén Cabrera Martínez <[email protected]>
EXPOSE 8069 8071 8072
ENV LANG C.UTF-8

RUN apt-get update \
&& apt-get install \
software-properties-common \
wget \
gnupg2 \
-y

RUN add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" -y; \
wget --quiet -O - https://postgresql.org/media/keys/ACCC4CF8.asc | \
apt-key add -

RUN apt-get update && apt-get install \
git \
libssl1.0-dev \
locales \
net-tools \
node-clean-css \
node-less \
postgresql-client-9.6 \
python3-apt \
python3-babel \
python3-cups \
python3-dateutil \
python3-decorator \
python3-dev \
python3-docutils \
python3-feedparser \
python3-gevent \
python3-geoip \
python3-jinja2 \
python3-lxml \
python3-mako \
python3-mock \
python3-openid \
python3-openssl \
python3-passlib \
python3-pip \
python3-psutil \
python3-psycopg2 \
python3-pydot \
python3-pyinotify \
python3-pyldap \
python3-pyparsing \
python3-pypdf2 \
python3-qrcode \
python3-renderpm \
python3-reportlab \
python3-requests \
python3-simplejson \
python3-tz \
python3-unicodecsv \
python3-unittest2 \
python3-vatnumber \
python3-vobject \
python3-watchdog \
python3-werkzeug \
python3-yaml \
xauth \
xfonts-75dpi \
xfonts-base \
xfonts-utils \
-y

# Pone trusty pero estamos usando la imagen de xenial
#RUN apt-get deb=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
#RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb

RUN pip3 install \
backports.functools_lru_cache \
bokeh \
cssutils \
dbfpy \
html2text \
libsass \
odoorpc \
ofxparse \
openupgradelib \
num2words \
pandas \
psycogreen \
twilio \
unidecode \
xlrd \
zeep \
zklib
RUN mkdir /opt/odoo; mkdir /var/log/odoo; mkdir /var/lib/odoo; mkdir /opt/repos && mkdir /opt/repos/oca
RUN useradd --home /opt/odoo --shell /bin/bash odoo
RUN chown -R odoo:odoo /opt/odoo; chown -R odoo:odoo /var/lib/odoo; \
chown -R odoo:odoo /var/log/odoo; chown -R odoo:odoo /opt/repos

# Con lo siguiente, cambiamos al usuario odoo y el path donde ejecuta los
# comandos que se indiquen después.
USER odoo
WORKDIR /opt/odoo
RUN git clone --branch 12.0 --depth 1 https://github.com/oca/ocb.git /opt/odoo

# Aquí van los repos oca
WORKDIR /opt/repos/oca
{% for repo_url, last_commit in repo_dict.items() -%}
{% if loop.first -%}
RUN \
{%- endif %}
git clone --branch 12.0 --depth 1 {{ repo_url}}; {% if not loop.last -%} \{%- endif %}
{%- endfor %}

# Repositorios abiertos que no son de la oca ni de Praxya
# TODO

# Configuración
USER root
RUN mkdir /opt/config
COPY ./odoo-server.conf /opt/config/odoo-server.conf
ENV OPENERP_SERVER /opt/config/odoo-server.conf

RUN chown -R odoo:odoo /opt/config
RUN sed -i '/^#.*Storage/s/^#//' /etc/systemd/journald.conf
#RUN mkdir -p /var/lib/odoo \
#&& chown -R odoo /var/lib/odoo
#VOLUME ["/var/lib/odoo"]
# Mount /var/lib/odoo to allow restoring filestore and /mnt/extra-addons
# for users addons
RUN mkdir -p /mnt/extra-addons \
&& chown -R odoo:odoo /mnt/extra-addons \
&& chown -R odoo:odoo /var/lib/odoo
VOLUME ["/var/lib/odoo", "/mnt/extra-addons"]

COPY ./entrypoint.sh /opt/entrypoint.sh
RUN chown -R odoo:odoo /opt/entrypoint.sh
RUN ["chmod", "+x", "/opt/entrypoint.sh"]

USER odoo
ENTRYPOINT ["/opt/entrypoint.sh"]
CMD ["/opt/odoo/odoo-bin"]
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
certifi==2019.11.28
chardet==3.0.4
Deprecated==1.2.7
idna==2.8
Jinja2==2.10.3
MarkupSafe==1.1.1
PyGithub==1.44.1
PyJWT==1.7.1
requests==2.22.0
six==1.13.0
urllib3==1.25.7
wrapt==1.11.2
105 changes: 105 additions & 0 deletions scripts/get_repos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from github import Github, GithubException
import logging
from dev_token import token

_logger = logging.getLogger(__name__)
_logger.setLevel(logging.DEBUG)


# Add optional ConsoleHandler
ch = logging.StreamHandler()
ch.name = 'Console Logger'
ch.level = logging.DEBUG
_logger.addHandler(ch)

g = Github(token)


def get_all_oca_repos():
repos = g.get_organization("OCA").get_repos()
_logger.debug("Number of repos found for OCA: %d" % repos.totalCount)
return repos


well_known_repos = [
"https://github.com/OCA/account-analytic.git",
"https://github.com/OCA/account-budgeting.git",
"https://github.com/OCA/account-closing.git",
"https://github.com/OCA/account-consolidation.git",
"https://github.com/OCA/account-invoice-reporting.git",
"https://github.com/OCA/account-invoicing.git",
"https://github.com/OCA/account-financial-reporting.git",
"https://github.com/OCA/account-financial-tools.git",
"https://github.com/OCA/account-fiscal-rule.git",
"https://github.com/OCA/account-payment.git",
"https://github.com/OCA/bank-payment.git",
"https://github.com/OCA/bank-statement-import.git",
"https://github.com/OCA/bank-statement-reconcile.git",
"https://github.com/OCA/commission.git",
"https://github.com/OCA/community-data-files.git",
"https://github.com/OCA/contract.git",
"https://github.com/OCA/crm.git",
"https://github.com/OCA/e-commerce.git",
"https://github.com/OCA/event.git",
"https://github.com/OCA/hr.git",
"https://github.com/OCA/hr-timesheet.git",
"https://github.com/OCA/intrastat.git",
"https://github.com/OCA/knowledge.git",
"https://github.com/OCA/l10n-spain.git",
"https://github.com/OCA/management-system.git",
"https://github.com/OCA/manufacture.git",
"https://github.com/OCA/manufacture-reporting.git",
"https://github.com/OCA/margin-analysis.git",
"https://github.com/OCA/operating-unit.git",
"https://github.com/OCA/partner-contact.git",
"https://github.com/OCA/pos.git",
"https://github.com/OCA/product-attribute.git",
"https://github.com/OCA/product-variant.git",
"https://github.com/OCA/project.git",
"https://github.com/OCA/project-reporting.git",
"https://github.com/OCA/purchase-reporting.git",
"https://github.com/OCA/purchase-workflow.git",
"https://github.com/OCA/reporting-engine.git",
"https://github.com/OCA/rma.git",
"https://github.com/OCA/sale-financial.git",
"https://github.com/OCA/sale-reporting.git",
"https://github.com/OCA/sale-workflow.git",
"https://github.com/OCA/server-tools.git",
"https://github.com/OCA/social.git",
"https://github.com/OCA/stock-logistics-barcode.git",
"https://github.com/OCA/stock-logistics-tracking.git",
"https://github.com/OCA/stock-logistics-transport.git",
"https://github.com/OCA/stock-logistics-warehouse.git",
"https://github.com/OCA/stock-logistics-workflow.git",
"https://github.com/OCA/web.git",
"https://github.com/OCA/website.git",
"https://github.com/OCA/website-cms.git",
]


def create_repo_dict():
# TODO: actually make this variable
branch = "12.0"
repo_dict = dict()
for repo in get_all_oca_repos():
# print(repo.clone_url)
# print(repo.name)
try:
if repo.clone_url in well_known_repos:
repo_dict[repo.clone_url] = repo.get_branch(branch).commit.sha
# print(repo.get_branch(branch).commit)
except GithubException:
# print("This repo has no %s branch" % branch)
pass
return repo_dict


def main():
print(create_repo_dict())


if __name__ == "__main__":
main()
15 changes: 15 additions & 0 deletions scripts/render_dockerfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from jinja2 import FileSystemLoader, Environment
import get_repos

repo_dict = get_repos
env = Environment(loader=FileSystemLoader('../'))
template = env.get_template('Dockerfile.jinja2')
output_from_parsed_template = template.render(
repo_dict={
"https://github.com/caca": "asedfasdf",
}
)
print(output_from_parsed_template)