GithubHelp home page GithubHelp logo

nginx-gohttp's Introduction

This example has been moved to Awesome Compose.

nginx-gohttp

Compose app skeleton with two services:

  • frontend: nginx server that forwards requests to the backend. Nginx listens on port 80 which is mapped by docker-compose to 8080 on the localhost.

  • backend: Go http server which servers an ascii drawing and greeting message

Project structure

.
├── backend
│   ├── Dockerfile
│   └── main.go
├── docker-compose.yml
└── frontend
    ├── Dockerfile
    └── nginx.conf

Deploy it with docker-compose:

$ docker-compose up -d
Creating network "nginx-gohttp_default" with the default driver
Building frontend
Step 1/2 : FROM nginx:alpine
 ---> 48c8a7c47625
Step 2/2 : COPY nginx.conf /etc/nginx/conf.d/default.conf
 ---> Using cache
 ---> 9d5f008155e5

Successfully built 9d5f008155e5
Successfully tagged nginx-gohttp_frontend:latest
WARNING: Image for service frontend was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating nginx-gohttp_backend_1 ... done
Creating nginx-gohttp_frontend_1 ... done

Check that containers are running

$ docker-compose ps
         Name                    Command           State          Ports        
-------------------------------------------------------------------------------
nginx-gohttp_backend_1    /usr/local/bin/backend   Up                          
nginx-gohttp_frontend_1   nginx -g daemon off;     Up      0.0.0.0:8080->80/tcp

The Compose app was deployed successfully if a query to localhost:8080 returns the following messsage

$ curl localhost:8080

          ##         .
    ## ## ##        ==
 ## ## ## ## ##    ===
/"""""""""""""""""\___/ ===
{                       /  ===-
\______ O           __/
 \    \         __/
  \____\_______/

	
Hello from Docker!

Stop and remove containers

$ docker-compose down
Stopping nginx-gohttp_frontend_1 ... done
Stopping nginx-gohttp_backend_1  ... done
Removing nginx-gohttp_frontend_1 ... done
Removing nginx-gohttp_backend_1  ... done
Removing network nginx-gohttp_default

nginx-gohttp's People

Contributors

aiordache avatar justincormack 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.