F
F
frontendo2017-12-30 17:57:02
Software Deployment
frontendo, 2017-12-30 17:57:02

What is the correct method to deploy an application in docker containers on a vps?

I implemented a demo application on nodejs, then when the moment came to roll it out to the server, I decided to use docker and
created a configuration file

version: "3"
services:
  nginx:
    image: nginx:1.13-alpine
    restart: always
    ports:
      - "80:80"
    depends_on:
      - node
    links:
      - "node"
    volumes: 
      - "./nginx:/etc/nginx/conf.d"
      - "./static:/var/www/static"

  node:
    build: 
      context: ./server
      dockerfile: Dockerfile
    volumes:
      - ./server:/var/www/server
      - ./static:/var/www/static
      - ./logs:/var/www/logs
    depends_on:
      - db
      - redis
    links:
      - "db"
      - "redis"
    command: pm2-docker start /var/www/server/run.json --no-auto-exit
    environment:
      SQL_HOST: db
      SQL_USER: postgres
      SQL_PASSWORD: postgres
      SQL_DB: postgres
      REDIS_HOST: redis

  db: 
    image: postgres:10-alpine
    volumes:
      - "./server:/var/www/server"
      - "./pg:/var/www/pgdata"
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: postgres
      PGDATA: /var/www/pgdata

  redis: 
    image: redis:4-alpine
    volumes:
      - ./redis/conf/redis.conf:/usr/local/etc/redis/redis.conf

Now I can’t find a clear explanation of how it is better to deploy in my case. I thought to add a container for nodejs to dockerhub and just run the docker-compose command on the server exactly as I do it now on my computer. But I googled it, it turns out that people use additional tools for deployment. For example, the documentation suggests Docker Swarm, Docker Cloud Agent, and there are other third-party tools. But it seems to me that this is all redundant for deploying an application on one server for demonstration

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Puma Thailand, 2017-12-30
@opium

Of course, it's redundant, given that swarm and kubrnetes support up to five thousand servers and who the hell knows how many containers, this is not your case.

B
bacalastein, 2017-12-30
@bacalastein

orchestrators are superfluous in your case, most of them will require at least one more master server. Docker Compose is more than enough for testing and deployment within 1 server.

J
jar3b, 2018-02-16
@jar3b

Docker Swarm gives low overhead and can be run on a single machine very easily. It makes sense if you plan to increase the number of cars.
Another thing is that the author does not need Swarm here when it comes to deployment. I see 3 options:
1. We connect via SSH, we do it on the server git pull, then docker-compose up -d, everything is done by hand.
2. We use docker-machine. It works with both docker stack and old compose. There is a lot of information on the Internet, you can set up auto-deploy.
3. Use something like ansible, similar to the second option, but a more flexible solution and allows you to configure the server if you need a specific configuration, for example. Similarly, you can set up auto-deploy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question