Commit 5693787d authored by Nacho's avatar Nacho
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

.dockerignore

0 → 100644
+3 −0
Original line number Diff line number Diff line
*
!scripts
 No newline at end of file

.gitignore

0 → 100644
+2 −0
Original line number Diff line number Diff line
data
 No newline at end of file

.gitlab-ci.yml

0 → 100644
+103 −0
Original line number Diff line number Diff line
stages:
  - package
  - test-package
  - deploy

docker-build-dev:
  stage: package
  image: redmic/docker-gitlab
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  only:
    - branches
  except:
    - master
  script:
    - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}-latest .
    - docker push ${CI_REGISTRY_IMAGE}

docker-build-pro:
  stage: package
  image: redmic/docker-gitlab
  variables:
    DOCKER_DRIVER: overlay2
  services:
    - docker:dind
  only:
    - master
  script:
    - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} -t ${CI_REGISTRY_IMAGE}:latest .
    - docker push ${CI_REGISTRY_IMAGE}

container_scanning:
  stage: test-package
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  only:
    - branches
  except:
    - master
  script:
    - docker run -d --name db arminc/clair-db:latest
    - docker run -p 6060:6060 --link db:postgres -d --name clair arminc/clair-local-scan:v2.0.1
    - apk add -U wget ca-certificates
    - docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
    - docker pull ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}
    - wget https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64
    - mv clair-scanner_linux_amd64 clair-scanner
    - chmod +x clair-scanner
    - touch clair-whitelist.yml
    - ./clair-scanner -c http://docker:6060 --ip $(hostname -i) -r gl-sast-container-report.json -l clair.log -w clair-whitelist.yml ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA} || true
  artifacts:
    paths: [gl-sast-container-report.json]


deploy-postgres-master-dev:
  stage: deploy
  image: redmic/docker-gitlab
  variables:
    DOCKER_DRIVER: overlay2
    SSH_REMOTE: ${DEV_SSH_REMOTE}
    SERVICE: ${CI_PROJECT_NAME}-master
    IMAGE_TAG: ${CI_COMMIT_SHA}
    COMPOSE_FILE: docker-compose.${CI_PROJECT_NAME}-master.tmpl.yml:docker-compose.${CI_PROJECT_NAME}-master.dev.yml
  services:
    - docker:dind
  script:
    - >
      deploy.sh DOCKER_ENV_CI_REGISTRY_IMAGE=${DOCKER_ENV_CI_REGISTRY_IMAGE} IMAGE_TAG=${IMAGE_TAG
      COMPOSE_FILE=${COMPOSE_FILE} POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
  environment:
    name: dev/master
  only:
    - dev
  when: manual

deploy-postgres-slave-dev:
  stage: deploy
  image: redmic/docker-gitlab
  variables:
    DOCKER_DRIVER: overlay2
    SSH_REMOTE: ${DEV_SSH_REMOTE}
    SERVICE: ${CI_PROJECT_NAME}-slave
    IMAGE_TAG: ${CI_COMMIT_SHA}
    COMPOSE_FILE: docker-compose.${CI_PROJECT_NAME}-slave.tmpl.yml:docker-compose.${CI_PROJECT_NAME}-slave.dev.yml
  services:
    - docker:dind
  script:
    - >
      deploy.sh DOCKER_ENV_CI_REGISTRY_IMAGE=${DOCKER_ENV_CI_REGISTRY_IMAGE} IMAGE_TAG=${IMAGE_TAG
      COMPOSE_FILE=${COMPOSE_FILE} POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
  environment:
    name: dev/slave
  only:
    - dev
  when: manual

Dockerfile

0 → 100644
+31 −0
Original line number Diff line number Diff line
FROM postgres:10.3

ENV PG_PORT="5432" \
	PG_MAX_CONNECTIONS="100" \
	PG_SHARED_PRELOAD_LIBRARIES="pg_cron" \
	PG_WAL_LEVEL="logical" \
	PG_MAX_WAL_SIZE="5GB" \
	POSTGRES_USER="postgres" \
	POSTGRES_PASSWORD="password" \
	PG_POSTGIS_VERSION="2.4" \
	CONFIG_PATH="/"


COPY scripts /tmp

RUN apt-get update \
	&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
		locales \
		postgresql-plpython-${PG_MAJOR} \
		postgresql-${PG_MAJOR}-cron \
		postgresql-${PG_MAJOR}-postgis-${PG_POSTGIS_VERSION} \
		postgresql-${PG_MAJOR}-postgis-${PG_POSTGIS_VERSION}-scripts \
        gettext-base \
	&& rm -rf /var/lib/apt/lists/* \
	&& localedef -i es_ES -c -f UTF-8 -A /usr/share/locale/locale.alias es_ES.UTF-8 \
	&& mv /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-entrypoint-origin.sh \
	&& mv /tmp/docker-entrypoint.sh /usr/local/bin/ \
	&& mv /tmp/pg_hba.conf /usr/share/postgresql/${PG_MAJOR}/pg_hba.conf.sample

ENV LANG es_ES.utf8
 No newline at end of file

README.md

0 → 100644
+14 −0
Original line number Diff line number Diff line
# DATABASE
Este repositorio es para guardar los elementos necesarios para preparar la base de datos. Este README está por hacer.

Ejecutar fichero sql desde consola

```
psql -U username -d myDataBase -a -f myInsertFile
```

# Extraer el schema desde una base de datos
```
pg_dump -h redmic.es -U postgres -W --schema=app --schema-only -d redmic > app.sql
```
 No newline at end of file