Skip to content

Instantly share code, notes, and snippets.

@x-yuri
x-yuri / docker: postgres: auth settings.md
Last active January 18, 2021 16:25
docker: postgres: auth settings #pg #docker #auth

docker: postgres: auth settings

There are three relevant environment variables: POSTGRES_USER, POSTGRES_DB, POSTGRES_PASSWORD. The first two determine username and database name of the superuser. Although postgres database is created in any case. Using POSTGRES_PASSWORD one can specify superuser password. Depending on presence or absence of the last one the init script decides the [authentication method][1] for all remote connection. With POSTGRES_PASSWORD it's md5, without trust (host all all all $authMethod).

@x-yuri
x-yuri / docker-compose.yml: variables.md
Last active October 26, 2019 07:00
docker-compose.yml: variables

In docker-compose.yml one can use variables either from environment, or from .env file. They don't automatically propagate into the containers. Variables added with env_file option are available only in the containers. environment option overrides values from env_file.

docker-compose.yml:

version: '3'

services:
  bash:
@x-yuri
x-yuri / docker: copying directories.md
Last active October 28, 2019 10:43
docker: copying directories

When docker is told to copy directory a to directory b, it copies contents of a into b. b and any of its parents might not exist:

FROM alpine

RUN mkdir src && touch src/f1

FROM alpine
@x-yuri
x-yuri / docker: mongo.md
Last active February 20, 2023 12:28
docker: mongo

Without either MONGO_INITDB_ROOT_USERNAME, or MONGO_INITDB_ROOT_PASSWORD the access is unrestricted.

docker-compose.yml:

version: '3'

services:
  mongo:
    image: mongo:4
@x-yuri
x-yuri / this is where we put our bugs.md
Created October 31, 2019 22:08
this is where we put our bugs
if (cluster.isMaster) {
  // ...
  // The important thing is that the master does very little,
  // increasing our resilience to unexpected errors.
  // ...
} else {
  // the worker
  //
 // This is where we put our bugs!
@x-yuri
x-yuri / Updating bundler 1.x to 2.x.md
Last active June 19, 2024 15:46
Updating bundler 1.x to 2.x

Let's prepare a stage for the experiments:

$ docker run --rm -it ruby:alpine sh
$ apk add build-base git
$ mkdir app
$ cd app
$ gem install bundler

$ gem list -e bundler
@x-yuri
x-yuri / web-console: allow private networks.md
Last active January 24, 2021 11:42
#web-console #ruby #rails #docker

web-console: allow private networks

config/environments/development.rb:

require 'socket'
require 'ipaddr'
Rails.application.configure do
  ...
 config.web_console.permissions = Socket.getifaddrs
@x-yuri
x-yuri / Running a site in production with Docker Compose.md
Last active August 5, 2021 08:40
#docker #docker-compose #alpine #debian #ruby #pg #puma #nginx #mina

Running a site in production with Docker Compose

TODO

  • pg: use superuser account (create extension)
  • docker-compose.yml: prefer dicts over arrays
  • docker-compose.yml: no explicit network is needed
  • add UID variable
  • .dockerignore
  • docker-compose.yml: environment after env_file
@x-yuri
x-yuri / How to make Electron app log to console (terminal).md
Created December 7, 2019 10:30
How to make Electron app log to console (terminal)