master fdb3c5708ea8 cached
7 files
5.4 KB
1.7k tokens
1 requests
Download .txt
Repository: jdleesmiller/docker-chat-demo
Branch: master
Commit: fdb3c5708ea8
Files: 7
Total size: 5.4 KB

Directory structure:
gitextract_ktr6e2lm/

├── .dockerignore
├── Dockerfile
├── README.md
├── docker-compose.yml
├── index.html
├── index.js
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .dockerignore
================================================
.dockerignore
.git
docker-compose*.yml
Dockerfile
node_modules


================================================
FILE: Dockerfile
================================================
FROM node:10.16.3 AS development

RUN mkdir /srv/chat && chown node:node /srv/chat

USER node

WORKDIR /srv/chat

COPY --chown=node:node package.json package-lock.json ./

RUN npm install --quiet

FROM node:10.16.3-slim AS production

USER node

WORKDIR /srv/chat

COPY --from=development --chown=root:root /srv/chat/node_modules ./node_modules

COPY . .

CMD ["node", "index.js"]


================================================
FILE: README.md
================================================
# Docker Chat Demo

Companion repo for this article on my blog:
- [Lessons from Building a Node App in Docker](https://jdlm.info/articles/2019/09/06/lessons-building-node-app-docker.html) (2019 update).
- [Lessons from Building a Node App in Docker](http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html) (2016 original).

Contains step-by-step examples used in the article to get the [socket.io chat example](http://socket.io/get-started/chat) running in Docker.

## 2019 Update

Each step has a tag:
- [2019-01-bootstrapping](https://github.com/jdleesmiller/docker-chat-demo/tree/2019-01-bootstrapping)
- [2019-02-bootstrapped](https://github.com/jdleesmiller/docker-chat-demo/tree/2019-02-bootstrapped)
- [2019-03-dependencies](https://github.com/jdleesmiller/docker-chat-demo/tree/2019-03-dependencies)
- [2019-04-the-app](https://github.com/jdleesmiller/docker-chat-demo/tree/2019-04-the-app)
- [2019-05-dev-prod](https://github.com/jdleesmiller/docker-chat-demo/tree/2019-05-dev-prod)

## 2016 Original

Here's the [original code from 2016](https://github.com/jdleesmiller/docker-chat-demo/tree/2016).

Each step has a tag:
- [01-bootstrapping](https://github.com/jdleesmiller/docker-chat-demo/tree/01-bootstrapping)
- [02-bootstrapped](https://github.com/jdleesmiller/docker-chat-demo/tree/02-bootstrapped)
- [03-dependencies](https://github.com/jdleesmiller/docker-chat-demo/tree/03-dependencies)
- [04-the-app](https://github.com/jdleesmiller/docker-chat-demo/tree/04-the-app)
- [05-dev-prod](https://github.com/jdleesmiller/docker-chat-demo/tree/05-dev-prod)

## License

The ISC license:

Copyright (c) 2016–2019, John Lees-Miller

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


================================================
FILE: docker-compose.yml
================================================
version: '3.7'

services:
  chat:
    build:
      context: .
      target: development
    command: npx nodemon index.js
    ports:
      - '3000:3000'
    volumes:
      - .:/srv/chat
      - chat_node_modules:/srv/chat/node_modules

volumes:
  chat_node_modules:


================================================
FILE: index.html
================================================
<!doctype html>
<html>
  <head>
    <title>Socket.IO chat</title>
    <style>
      * { margin: 0; padding: 0; box-sizing: border-box; }
      body { font: 13px Helvetica, Arial; }
      form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
      form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
      form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
      #messages { list-style-type: none; margin: 0; padding: 0; }
      #messages li { padding: 5px 10px; }
      #messages li:nth-child(odd) { background: #eee; }
      #messages { margin-bottom: 40px }
    </style>
  </head>
  <body>
    <ul id="messages"></ul>
    <form action="">
      <input id="m" autocomplete="off" /><button>Send</button>
    </form>
    <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
    <script src="https://code.jquery.com/jquery-1.11.1.js"></script>
    <script>
      $(function () {
        var socket = io();
        $('form').submit(function(){
          socket.emit('chat message', $('#m').val());
          $('#m').val('');
          return false;
        });
        socket.on('chat message', function(msg){
          $('#messages').append($('<li>').text(msg));
          window.scrollTo(0, document.body.scrollHeight);
        });
      });
    </script>
  </body>
</html>


================================================
FILE: index.js
================================================
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = process.env.PORT || 3000;

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(socket){
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
  });
});

http.listen(port, function(){
  console.log('listening on *:' + port);
});


================================================
FILE: package.json
================================================
{
  "name": "chat",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/jdleesmiller/docker-chat-demo.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/jdleesmiller/docker-chat-demo/issues"
  },
  "homepage": "https://github.com/jdleesmiller/docker-chat-demo#readme",
  "dependencies": {
    "express": "^4.17.1",
    "socket.io": "^1.7.4"
  },
  "devDependencies": {
    "nodemon": "^1.19.2"
  }
}
Download .txt
gitextract_ktr6e2lm/

├── .dockerignore
├── Dockerfile
├── README.md
├── docker-compose.yml
├── index.html
├── index.js
└── package.json
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6K chars).
[
  {
    "path": ".dockerignore",
    "chars": 63,
    "preview": ".dockerignore\n.git\ndocker-compose*.yml\nDockerfile\nnode_modules\n"
  },
  {
    "path": "Dockerfile",
    "chars": 381,
    "preview": "FROM node:10.16.3 AS development\n\nRUN mkdir /srv/chat && chown node:node /srv/chat\n\nUSER node\n\nWORKDIR /srv/chat\n\nCOPY -"
  },
  {
    "path": "README.md",
    "chars": 2361,
    "preview": "# Docker Chat Demo\n\nCompanion repo for this article on my blog:\n- [Lessons from Building a Node App in Docker](https://j"
  },
  {
    "path": "docker-compose.yml",
    "chars": 266,
    "preview": "version: '3.7'\n\nservices:\n  chat:\n    build:\n      context: .\n      target: development\n    command: npx nodemon index.j"
  },
  {
    "path": "index.html",
    "chars": 1370,
    "preview": "<!doctype html>\n<html>\n  <head>\n    <title>Socket.IO chat</title>\n    <style>\n      * { margin: 0; padding: 0; box-sizin"
  },
  {
    "path": "index.js",
    "chars": 429,
    "preview": "var app = require('express')();\nvar http = require('http').Server(app);\nvar io = require('socket.io')(http);\nvar port = "
  },
  {
    "path": "package.json",
    "chars": 619,
    "preview": "{\n  \"name\": \"chat\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\""
  }
]

About this extraction

This page contains the full source code of the jdleesmiller/docker-chat-demo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (5.4 KB), approximately 1.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!