Все Docker штуки опущены в директорию docker.

Production Docker контейнер теперь использует alpine linux вместо пустого scratch
В production Docker контейнер добавлен docker-entrypoint.sh, который автоматически создаёт конфиг по умолчанию.
This commit is contained in:
ErickSkrauch
2017-09-04 20:24:55 +03:00
parent ac714de8df
commit eab7c6ecaa
10 changed files with 91 additions and 21 deletions

9
docker/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM alpine:3.6
COPY docker/docker-entrypoint.sh /usr/local/bin/
COPY docker/config.dist.yml /usr/local/etc/minecraft-skinsystem/
COPY minecraft-skinsystem /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["serve"]

51
docker/config.dist.yml Normal file
View File

@@ -0,0 +1,51 @@
# Main server configuration. Actually you don't want to change it,
# but you able to change host or port, that will be used by serve command
server:
host: # leave host empty to allow Docker publish port
port: 80
# Worker listen to AMQP events, so it should know how to connect to any
# AMQP provider (actually RabbitMQ). You should not escape any vhost
# characters, 'cause it will be done by application automatically
amqp:
host: rabbitmq
port: 5672
username: minecraft-skinsystem-app
password: minecraft-skinsystem-app-password
vhost: /
# Both of web or worker depends on storage.
storage:
# For now app require Redis and don't support any other backends to store
# skins, but in the future we can have more backends. Poll size tune amount
# of connections to the redis. It's not recommended to set it less then 2
# because it will lead to panic on high load.
redis:
host: redis
port: 6379
poolSize: 10
# Filesystem storage used to store capes. basePath specify absolute or relative
# path to storage and capesDirName specify which folder in this base path will
# be used to search capes.
filesystem:
basePath: /data
capesDirName: capes
# Accounts Ely.by internal API will be used in cases, when by some reasons
# information about user will be unavailable in the app storage.
api:
accounts:
host: https://account.ely.by
id: app-id
secret: secret
scopes:
- internal_account_info
# StatsD can be used to collect metrics
# statsd:
# addr: localhost:3746
# Sentry can be used to collect app errors
# sentry:
# dsn: https://public:private@your.sentry.io/1

View File

@@ -0,0 +1,46 @@
# This compose file contains necessary docker-compose config to quick start
# services required by app. Ports published to host.
#
# Usage:
# 1. Clone this file as docker-compose.yml:
# cp docker/docker-compose.dev.yml docker-compose.yml
#
# 2. If necessary, then you can fix configuration to your environment.
# Then start all services:
# docker-compose up -d
#
# 3. Pass to the project configuration links to this services:
# amqp:
# host: localhost
# port: 5672
# username: ely
# password: ely
# vhost: /ely
#
# storage:
# redis:
# host: localhost
# port: 6379
# poolSize: 10
#
# 4. After job is done all services can be stopped:
# docker-compose stop
version: '2'
services:
redis:
image: redis:3.2-32bit
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
rabbitmq:
image: rabbitmq:3.6-management-alpine
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: "ely"
RABBITMQ_DEFAULT_PASS: "ely"
RABBITMQ_DEFAULT_VHOST: "/ely"

View File

@@ -0,0 +1,34 @@
version: '2'
services:
web:
image: registry.ely.by/elyby/skinsystem:latest
restart: always
ports:
- "80:80"
links:
- redis
volumes:
- ./data/capes:/data/capes
- ./config/minecraft-skinsystem:/etc/minecraft-skinsystem
worker:
image: registry.ely.by/elyby/skinsystem:latest
restart: always
links:
- redis
- rabbitmq
command: ["amqp-worker"]
redis:
image: redis:3.2-32bit # 32-bit version used to decrease memory usage
restart: always
volumes:
- ./data/redis:/data
rabbitmq:
image: rabbitmq:3.6-alpine
restart: always
environment:
RABBITMQ_DEFAULT_USER: minecraft-skinsystem-app
RABBITMQ_DEFAULT_PASS: minecraft-skinsystem-app-password
RABBITMQ_DEFAULT_VHOST: /

15
docker/docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
set -e
CONFIG="/etc/minecraft-skinsystem/config.yml"
if [ ! -f "$CONFIG" ]; then
mkdir -p $(dirname "${CONFIG}")
cp /usr/local/etc/minecraft-skinsystem/config.dist.yml "$CONFIG"
fi
if [ "$1" = "serve" ] || [ "$1" = "amqp-worker" ]; then
set -- minecraft-skinsystem "$@"
fi
exec "$@"