Skip to content

Instantly share code, notes, and snippets.

View thatisuday's full-sized avatar

Uday Hiwarale thatisuday

View GitHub Profile
@thatisuday
thatisuday / docker-compose.yml
Created December 20, 2020 15:05
Docker Compose file with a restart policy.
# Compose file version
version: "3.9"
# services
services:
# frontend (php-apache web server)
frontend:
image: php:8.0.0-apache-buster
volumes:
- "./www:/var/www/html"
@thatisuday
thatisuday / restart-policies.csv
Last active December 20, 2020 14:41
Docker container restart policies.
Flag Description
no Do not automatically restart the container. (the default)
on-failure Restart the container if it exits due to an error, which manifests as a non-zero exit code.
always Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in restart policy details)
unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.
@thatisuday
thatisuday / docker-compose.yml
Last active December 20, 2020 14:00
A sample Docker Compose file with networks.
# Compose file version
version: "3.9"
# services
services:
# frontend (php-apache web server)
frontend:
image: php:8.0.0-apache-buster
volumes:
- "./www:/var/www/html"
@thatisuday
thatisuday / server.js
Created December 20, 2020 10:36
A sample Express sever to fetch-and-send a list of users.
const express = require( "express" );
const axios = require( "axios" );
const redis = require( "redis" );
// create redis client
const redisClient = redis.createClient( "redis://cache:6379" );
redisClient.on( 'error', ( error ) => {
console.log( '[BACKEND]: redis connection error', error );
} );
@thatisuday
thatisuday / Dockerfile
Created December 20, 2020 10:33
A sample Dockerfile for an Express HTTP server.
# parent image
FROM node:15.4.0-alpine3.10
# set working directory
WORKDIR /app
# install dependencies
ADD package.json package-lock.json ./
RUN npm install --production
@thatisuday
thatisuday / index.php
Created December 20, 2020 10:31
A sample PHP script to display users data.
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Docker Compose App</title>
</head>
<body>
<ul>
<?php
@thatisuday
thatisuday / docker-compose.yml
Created December 20, 2020 10:28
A sample Docker Compose file for a web application to display a users list.
# Compose file version
version: "3.9"
# services
services:
# frontend (php-apache web server)
frontend:
image: php:8.0.0-apache-buster
volumes:
- "./www:/var/www/html"
@thatisuday
thatisuday / docker-compose.yml
Last active December 19, 2020 20:42
Docker Compose file with service level environment variables.
# Compose file version
version: "3.9"
# services
services:
# frontend web service
frontend:
image: nginx:${NGINX_VERSION}
volumes:
@thatisuday
thatisuday / docker-compose.yml
Last active December 19, 2020 18:44
Docker Compose file with build arguments.
# Compose file version
version: "3.9"
# services
services:
# frontend web service
frontend:
build:
context: ./frontend
@thatisuday
thatisuday / docker-compose.yml
Last active April 4, 2021 07:32
Docker Compose file variable substitution
# Compose file version
version: "3.9"
# services
services:
# frontend web service
frontend:
image: nginx:${NGINX_VERSION}
volumes: