Code Monkey home page Code Monkey logo

docker-workshop's Introduction

Docker Workshop

This is a repository for a humble docker workshop.
The challenge of this repository is to build a dockerfile and a docker-compose.yml for a startup called HateCss,

Challenge context

Suppose that you're a frontend deleveloper in a startup called HateCss.
Your job, in the recently created enterprise, is to build its official website.
As a smart developer, you know that creating an website, in most part of the cases, requires the developer to install a bunch of dependencies and these dependencies might have some conflicts with other tools in your computer. To solve this issue (and many others) you have decided to execute this project inside a docker container.

The HateCss project

To build a dockerfile you must at least have a basic knowledge about the project:

  • The minimum necessary files to execute the code;
  • The sequece of commands to build and/or run.

The HateCss website project runs using react and nodejs. If you're already familiar with the structure of a NodeJs project feel free to jump this section.

Dependencies

To build and run the website in your local machine you must have to installed nodejs.

Commands

Before running the project, a developer must have installed the necessary libraries to execute it. The installation can be perfomed with the following command:

npm install

In the end, you will notice that a folder called node_modules will be created in the root of the project, which stores the dependent libraries and a file called package-lock.json.

More information about package-lock.json.

To run the project you must execute:

npm start

Folder structure

├──  node_modules/
├──  package-lock.json
├──  package.json
├──  public/
├──  README.md
└──  src/

#The task

This will be a simple dockerfile.
As we have seem before, we know that to execute our project in our local machine we must execute the following commands:

Install node 
npm install 
npm start

Thus, we must build our dockerfile in a way that it performs these three operations. Can you do that?

Basic commands

The most basic commands to build a dockerfile are:

  • FROM: uses a base image to build the dockerfile.
  • WORKDIR: sets the working directory inside the container.
  • RUN: It will executes this command to build the image. Which means that the image will contain the files generated by this command.
  • CMD: It can only have one CMD instruction per dockerfile. The purpose of these instruction is to provide the default command when the container is executed. Thus, when you execute a container, this command will automatically take action.
  • ADD: Copies new files from your computer and adds it to the image at a specified path.
  • COPY: This instruction copies new files from your computer and adds it to the container at a specified path.
  • ENV: set up the environment variables.
  • etc...

The full list of commands can be checked in the official website.

You can also check this list of docker commands

docker-workshop's People

Contributors

jumaruba avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.