Fran Moya
Rock developer and web guitarist!
MacOS: https://docs.docker.com/docker-for-mac/install/
Ubuntu: https://docs.docker.com/engine/install/ubuntu/
Let's install Docker for Ubuntu:
Windows: https://docs.docker.com/docker-for-windows/install/
# Remove Docker Engine previous files
sudo apt-get remove docker docker-engine docker.io containerd runc
# Update system packages
sudo apt-get update
# Setup Docker repository
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# Add Docker GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Check GPG key
sudo apt-key fingerprint 0EBFCD88
# Install Docker from repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Update system packages
sudo apt-get update
# Install Docker Engine
sudo apt-get install docker-ce docker-ce-cli containerd.io
# Check Docker installation
sudo docker run hello-world# Create docker group
sudo groupadd docker
# Add user to docker group
sudo usermod -aG docker $USERPost installation, only for ubuntu Users
Now, log out for your terminal session and enter again and check your current user group
# Check user group
groups $USER
# Log out from terminal or run following command
newgrp docker
# Now check you can run docker commands without sudo
docker run hello-worldHERE! https://docs.docker.com/compose/install/
Oh such a wonderfull surprise, Docker for MacOs installer already include docker-compose, but do you know which installer doesn't?
Let's install Docker Compose for Ubuntu:
# Easy, I promise
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Then apply permissions
sudo chmod +x /usr/local/bin/docker-composeIt should be enough, lets play a little with it!
# Move to your favourite folder ;)
cd my_favourite_folder
# Clone repository
git clone git@github.com:StringProjects/t3po.git && cd t3po
And now, open our Dockerfile and docker-compose.yml
Create a file called docker-dev.env in /docker/development with the following content:
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=postgres
NODE_ENV=development
RAILS_ENV=development
FROM ruby:2.6.5
# Install Node && Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get install -y nodejs
RUN apt-get update && apt-get install -y yarn
# Set docker user var
ENV DOCKER_USER root
# Set the app directory var
ENV APP_HOME /opt/t3po
# Set entrypoint file
ADD ./docker/docker-entrypoint.sh /
RUN chmod +x docker-entrypoint.sh
# Install bundler
ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
BUNDLE_JOBS=2 \
BUNDLE_PATH=/vendor/bundle
# Copy app on path
ADD . $APP_HOME
WORKDIR $APP_HOME
USER $DOCKER_USER
##################### INSTALLATION ENDS #####################
EXPOSE 3000
EXPOSE 3035
EXPOSE 80
EXPOSE 443
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
version: '3.8'
services:
postgres:
image: postgres:9.6-alpine
ports:
- "5433"
volumes:
- t3po_db:/var/lib/postgresql/data
environment:
- POSTGRES_PASSWORD=postgres
restart: always
t3po:
build: ./../../../t3po/
image: t3po:latest
ports:
- "3000:3000"
entrypoint: ["/docker-entrypoint.sh"]
command: "bundle exec foreman start -f Procfile.dev-server"
volumes:
- ./../../../t3po/:/opt/t3po
- t3po_rvm_gems:/vendor/bundle
- t3po_node_modules:/opt/t3po/node_modules
- $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
environment:
- BOOTSNAP_DISABLED=true
- SSH_AUTH_SOCK
env_file:
- ./docker-dev.env
depends_on:
- postgres
links:
- postgres:db
stdin_open: true
tty: true
restart: always
volumes:
t3po_db:
t3po_rvm_gems:
t3po_node_modules:
# Run all services in project root path
docker-compose -f docker/development/docker-compose.yml up
By Fran Moya