Skip to content

Instantly share code, notes, and snippets.

@gbzarelli
Last active May 14, 2019 18:03
Show Gist options
  • Save gbzarelli/fc89c6f723b7549321036a3540164db6 to your computer and use it in GitHub Desktop.
Save gbzarelli/fc89c6f723b7549321036a3540164db6 to your computer and use it in GitHub Desktop.
GitLab with Docker

Create GITLAB (docker-compose.yml):

web:
  image: 'gitlab/gitlab-ce:latest'
  container_name: gitlab
  restart: always
  hostname: 'gitlab.helpdev.com.br'
  environment:
    GITLAB_OMNIBUS_CONFIG: |
      external_url 'http://gitlab.helpdev.com.br'
  ports:
    - '80:80'
  volumes:
    - '/opt/repositorios/gitlab/config:/etc/gitlab'
    - '/opt/repositorios/gitlab/logs:/var/log/gitlab'
    - '/opt/repositorios/gitlab/data:/var/opt/gitlab'

Documentação:

https://hub.docker.com/r/gitlab/gitlab-ce/
https://docs.gitlab.com/omnibus/docker/

Run:

$docker-compose up -d

Gitlab - Backup and Restore

https://docs.gitlab.com/ee/raketasks/backup_restore.html
	docker exec -it <container name> gitlab-rake gitlab:backup:create
	docker exec -it <container name> gitlab-rake gitlab:backup:restore
	( Dir backup: <dir data>/backups )
	Obs: Restaure o backup sempre na mesma versão do gitlab.

Para inserir na CRON: (EXECUÇÃO AS 18:30, todos os dias)
	30 18   * * *   root    docker exec gitlab_helpdev gitlab-rake gitlab:backup:create CRON=1

Upgrade GitLab:

1 - Esteja com o ambiente todo configurado. E rodando.
2 - Faça um backup para segurança
3 - Provided you installed GitLab using docker-compose, all you have to do is run docker-compose pull and docker-compose up -d to download a new release and upgrade your GitLab instance.

Nexus3 - Repositorio Maven

docker run -d -p 5858:8081 --restart=always --name nexus -v /opt/nexus-data:/nexus-data sonatype/nexus3
Caso tenha backup:
	chown 200 -R /opt/nexus-data

####! UTILS !####

Comandos uteis

docker ps -a
docker logs <container name>
docker rm <container name>
docker rmi <image_name>
docker exec -it <container name> bash

Sample create a debian image:

docker pull debian
docker run -it --name dockerName debian
docker start dockerName
docker attach dockerName OR docker exec -it dockerName bash


Build context example

Create a directory for the build context and cd into it. Write “hello” into a text file named hello and create a Dockerfile that runs cat on it. Build the image from within the build context (.):

mkdir myproject && cd myproject
echo "hello" > hello
echo -e "FROM busybox\nCOPY /hello /\nRUN cat /hello" > Dockerfile
docker build -t helloapp:v1 .

Move Dockerfile and hello into separate directories and build a second version of the image (without relying on cache from the last build). Use -f to point to the Dockerfile and specify the directory of the build context:

mkdir -p dockerfiles context
mv Dockerfile dockerfiles && mv hello context
docker build --no-cache -t helloapp:v2 -f dockerfiles/Dockerfile context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment