Coder Social home page Coder Social logo

fullcycle-docker's Introduction

fullcycle-docker

Tasks from the course Full Cycle 2.0 on Docker module

1. Build Go app using multistage docker

A simple multistage dockerfile to build an app in Go lang.

Useful commands for build with Docker

Useful commands:

# Build image
docker build -t adrianokerber/codeeducation go

# Build image seeing all logs (ex: using 'RUN ls' or similar commands)
docker build -t adrianokerber/codeeducation go --progress=plain --no-cache

# Run container
docker run adrianokerber/codeeducation

# Publish container
docker push adrianokerber/codeeducation

DockerHub image

Imagem adrianokerber/codeeducation no DockerHub

2. Build your development environment using docker-compose

Initialize all containers

docker-compose up -d

Initialize and build all containers

docker-compose up -d --build

Shutdown all containers

docker-compose down

Tip: use docker-compose or docker compose without dash.

Access the aplication with the browser using localhost:8080 to acess via Nginx (Reverse proxy) or localhost:3000 for direct connection to node app container. The application has two routes: / and /name/:yourName where the yourName parameter is the name for a new register on the DB.

Docker command tips

Build Docker image locally

docker build -t adrianokerber/laravel .

Run Docker image on a container

docker run -d --name laravel -p 8000:8000 adrianokerber/laravel

Remove all Docker containers

docker rm $(docker ps -aq) -f

Interact with container using Bash (Note: <container_name> is the name of your target container)

docker exec -it <container_name> bash

Other useful commands:

# List running containers
docker ps

# List images
docker images

# Remove container
docker rm <container_id>

# Remove image
docker rmi <image_id>

MySQL commands to manage database for dev

-- Enter bash of container
docker exec -it db bash

-- On MySQL container run this to access and complete password as "root"
mysql -uroot -p

-- Select database
use nodedb;

-- Create table
create table people

-- Select registers from table people
select * from people;

This project uses Gitmoji as commits' pattern along with a clear message

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.