OBJETIVO
O projeto tem como finalidade, a criação de um ambiente de desenvolvimento para uma aplicação web, utilizando a plataforma Docker. Toda a arquitetura foi desenvolvida em conjunto com os alunos Lucas Gabriel Moya Arantes Pereira e João Gustavo Rodrigues.
ESTRUTURA
- Toda base de código utilizada no back-end e front-end possui a seguinte estrutura:
CÓDIGOS UTILIZADOS
- Arquivo Dockerfile completo:
FROM php:7.4-apache
RUN docker-php-ext-install mysqli
- Arquivo docker-compose.yml completo:
# Use root/example user/password credentials
version: '3.1'
services:
php:
container_name: Apache
build:
context: .
dockerfile: Dockerfile
ports:
- 80:80
volumes:
- ./src:/var/www/html/
db:
image: mysql
container_name: MySQL
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example # password
volumes:
- mysql-data:/var/lib/mysql
adminer:
image: adminer
container_name: Adminer
restart: always
ports:
- 8080:8080
mailhog:
image: mailhog/mailhog
container_name: MailHog
ports:
- 1025:1025
- 8025:8025
ftpd_server:
image: stilliard/pure-ftpd
container_name: FTP
ports:
- '21:21'
- '30000-30009:30000-30009'
volumes:
# remember to replace /folder_on_disk/ with the path to where you want to store the files on the host machine
- 'folder_on_disk/data:/home/username/'
- 'folder_on_disk/passwd:/etc/pure-ftpd/passwd'
# uncomment for ssl/tls, see https://github.com/stilliard/docker-pure-ftpd#tls
# - "/folder_on_disk/ssl:/etc/ssl/private/"
# or ssl/tls with Let's Encrypt (cert and key as two files)
# - "/etc/letsencrypt/live//cert.pem:/etc/ssl/private/pure-ftpd-cert.pem"
# - "/etc/letsencrypt/live//privkey.pem:/etc/ssl/private/pure-ftpd-key.pem"
environment:
PUBLICHOST: 'localhost'
FTP_USER_NAME: server_files #username
FTP_USER_PASS: admin123 #password
FTP_USER_HOME: /home/username
# also for ssl/tls:
# ADDED_FLAGS: "--tls=2"
restart: always
rocketchat:
image: registry.rocket.chat/rocketchat/rocket.chat:latest
container_name: RocketChat
command: >
bash -c
"for i in `seq 1 30`; do
node main.js &&
s=$$? && break || s=$$?;
echo \"Tried $$i times. Waiting 5 secs...\";
sleep 5;
done; (exit $$s)"
restart: unless-stopped
volumes:
- ./uploads:/app/uploads
environment:
- PORT=3000
- ROOT_URL=http://localhost:3000
- MONGO_URL=mongodb://mongo:27017/rocketchat
- MONGO_OPLOG_URL=mongodb://mongo:27017/local
- MAIL_URL=smtp://smtp.email
#- HTTP_PROXY=http://proxy.domain.com
#- HTTPS_PROXY=http://proxy.domain.com
depends_on:
- mongo
ports:
- 3000:3000
labels:
- "traefik.backend=rocketchat"
- "traefik.frontend.rule=Host: your.domain.tld"
mongo:
image: mongo:4.0
container_name: MongoDB
restart: unless-stopped
volumes:
- ./data/db:/data/db
#- ./data/dump:/dump
command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1
labels:
- "traefik.enable=false"
# this container's job is just run the command to initialize the replica set.
# it will run the command and remove himself (it will not stay running)
mongo-init-replica:
image: mongo:4.0
command: >
bash -c
"for i in `seq 1 30`; do
mongo mongo/rocketchat --eval \"
rs.initiate({
_id: 'rs0',
members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
s=$$? && break || s=$$?;
echo \"Tried $$i times. Waiting 5 secs...\";
sleep 5;
done; (exit $$s)"
depends_on:
- mongo
# hubot, the popular chatbot (add the bot user first and change the password before starting this image)
hubot:
image: rocketchat/hubot-rocketchat:latest
container_name: Hubot
restart: unless-stopped
environment:
- ROCKETCHAT_URL=rocketchat:3000
- ROCKETCHAT_ROOM=GENERAL
- ROCKETCHAT_USER=bot
- ROCKETCHAT_PASSWORD=botpassword
- BOT_NAME=bot
# you can add more scripts as you'd like here, they need to be installable by npm
- EXTERNAL_SCRIPTS=hubot-help,hubot-seen,hubot-links,hubot-diagnostics
depends_on:
- rocketchat
labels:
- "traefik.enable=false"
volumes:
- ./scripts:/home/hubot/scripts
# this is used to expose the hubot port for notifications on the host on port 3001, e.g. for hubot-jenkins-notifier
ports:
- 3001:8080
volumes:
mysql-data:
COMANDOS UTILIZADOS
- Criação dos contêineres e executação em segundo plano:
docker-compose up -d
- Remoção dos contêineres criados:
docker-compose down