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

Ci #2

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open

Ci #2

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
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]

env:
COMPOSE_FILE: docker/docker-compose.yml
PYTHON_VERSION: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2

- name: Build and up manager
id: manager
run: |
make build SERVICES=manager
make start SERVICES=manager
docker ps
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.bucardorc
script.sh
.env
.env
25 changes: 11 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,37 @@
## Automate container recreation for dengue database ##
#######################################################

#######################################################
## Automate container recreation for dengue database ##
#######################################################

include $(ENVFILE)
export
include .env

# Docker specific
ENV_FILE := .env
COMPOSE_FILE := docker/docker-compose.yml
NETWORK := infodengue
DOCKER := PYTHON_VERSION=$(PYTHON_VERSION) docker-compose -p $(NETWORK) -f $(COMPOSE_FILE) --env-file .env
NETWORK := bucardo
DOCKER := PYTHON_VERSION=$(PYTHON_VERSION) docker-compose -p $(NETWORK) -f $(COMPOSE_FILE) --env-file $(PWD)/$(ENV_FILE)
DOCKER_UP := $(DOCKER) up
DOCKER_RUN := $(DOCKER) run --rm
DOCKER_BUILD := $(DOCKER) build
DOCKER_STOP := $(DOCKER) rm --force --stop
DOCKER_EXEC := $(DOCKER) exec
DOCKER_NETWORK_REMOVE := $(DOCKER) down --remove-orphans
DOCKER_IMAGES := $(docker images -q 'docker_dengue_db' | uniq)
DOCKER_REMOVE := docker rmi --force $(DOCKER_IMAGES) ###
SERVICES := bucardo_manager

DOCKER_REMOVE := $(DOCKER) down --remove-orphans
SERVICES := manager

# Configure database in the container
build:
$(DOCKER_BUILD)

deploy:
start:
$(DOCKER_UP) -d

exec: deploy
$(DOCKER_EXEC) $(SERVICES) bash


remove_container:
stop:
$(DOCKER_STOP)
# $(DOCKER_REMOVE)


clean:
@find ./ -name '*.pyc' -exec rm -f {} \;
Expand Down
26 changes: 19 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM mdillon/postgis:9.6


RUN apt-get -qq update --yes \
&& apt-get -qq install --yes --no-install-recommends \
build-essential debconf git make wget\
Expand All @@ -13,11 +12,24 @@ RUN apt-get -qq update --yes \
RUN mkdir -p /var/log/bucardo /var/run/bucardo \
&& chown -R postgres:postgres /var/log/bucardo /var/run/bucardo

ADD docker/postgres_setup/* /docker-entrypoint-initdb.d/
# Install Bucardo:
RUN cd /tmp \
&& wget http://bucardo.org/downloads/Bucardo-5.4.1.tar.gz \
&& tar xvfz Bucardo-5.4.1.tar.gz \
&& mv Bucardo-5.4.1/ /Bucardo \
&& cd /Bucardo \
&& perl Makefile.PL \
&& apt install make \
&& make \
&& make install

COPY docker/.bucardorc $HOME/.bucardorc

COPY docker/postgres_setup/00-bucardo_roles.sql /docker-entrypoint-initdb.d/

COPY docker/entrypoint.sh /entrypoint.sh

#RUN mkdir /Bucardo
#ADD docker/script.sh /Bucardo
ADD docker/.bucardorc $HOME/.bucardorc
WORKDIR /Bucardo
RUN chmod +x /entrypoint.sh

EXPOSE 5432
# RUN ./entrypoint.sh
# CMD ["/bin/bash","-c","/entrypoint.sh"]
14 changes: 7 additions & 7 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
version: "3.8"
version: "3.3"
services:
bucardo_manager:
manager:
build:
context: ".."
dockerfile: "docker/Dockerfile"
env_file:
- ../.env
hostname: bucardo
hostname: db-manager
ports:
- "5432:5432"
volumes:
#- ./${DBDATA_DIR}/:Data
- "./Bucardo:/Bucardo"
- "./docker/pg_data/:/Data"
- ${DBDATA_MANAGER}/:/var/lib/postgresql/data
restart: always
command: -p 5432
expose:
- 5432
- "5432"
24 changes: 24 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# install
bucardo install --batch

# start
bucardo start

# add servidores
bucardo add dbdatabase hetzner dbhost=$HOST_HETZNER dbport=$PORT_HETZNER dbname=$DB_HETZNER dbuser=$USER_HETZNER dbpass=$PASS_HETZNER
bucardo add dbdatabase fgv dbhost=$HOST_FGV dbport=$PORT_FGV dbname=$DB_FGV dbuser=$USER_FGV dbpass=$PASS_FGV

# add banco de dados
bucardo add table % db=hetzner
bucardo add table % db=fgv

# add tabelas
bucardo add all tables --herd=hetzner_fgv db=hetzner
bucardo add all tables --herd=fgv_hetzner db=fgv

# add sync
bucardo add sync sync_hetznerTofgv relgroup=hetzner_fgv db=hetzner,fgv
bucardo add sync sync_fgvTohetzner relgroup=fgv_hetzner db=fgv,hetzner

# status
bucardo status all
5 changes: 5 additions & 0 deletions docker/postgres_setup/00-bucardo_roles.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE EXTENSION plperl;
CREATE LANGUAGE plperlu;
CREATE DATABASE bucardo;
CREATE USER bucardo SUPERUSER;
ALTER DATABASE bucardo OWNER TO bucardo;
51 changes: 0 additions & 51 deletions docker/postgres_setup/00-infodengue_roles.sql

This file was deleted.

15 changes: 15 additions & 0 deletions example_env_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Environment Variables
DBDATA_MANAGER=/Storage/dbdata_manager
PWD=/infodengue/infodengue-bucardo

HOST_HETZNER=172.0.0.2
PORT_HETZNER=5432
DB_HETZNER=bancodedados
USER_HETZNER=usuario
PASS_HETZNER=senha

HOST_FGV=172.0.0.3
PORT_FGV=5432
DB_FGV=bancodedados
USER_FGV=usuario
PASS_FGV=senha