Все 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

8
.gitignore vendored
View File

@ -2,14 +2,14 @@
/.idea
# Docker Compose file
docker-compose.yml
docker-compose.override.yml
/docker-compose.yml
/docker-compose.override.yml
# vendor
vendor
/vendor
# Cover output
.cover
# Local config
config.yml
/config.yml

View File

@ -55,7 +55,7 @@ build docker image:
<<: *setup_docker_environment
stage: build_docker_image
script:
- docker build -t $TEMP_IMAGE_NAME .
- docker build -t $TEMP_IMAGE_NAME -f docker/Dockerfile .
only:
- tags
- develop

View File

@ -1,6 +0,0 @@
FROM scratch
COPY ./minecraft-skinsystem /app/
ENTRYPOINT ["/app/minecraft-skinsystem"]
CMD ["serve"]

View File

@ -30,8 +30,8 @@ ENV переменными.
[docker-compose](https://docs.docker.com/compose/install/).
Для запуска последней версии проекта достаточно скопировать содержимое файла
[docker-compose.prod.yml](docker-compose.prod.yml) в файл `docker-compose.yml` непосредственно на месте
установки, после чего ввести в консоль команду:
[docker/docker-compose.prod.yml](docker/docker-compose.prod.yml) в файл `docker-compose.yml` непосредственно
на месте установки, после чего ввести в консоль команду:
```sh
docker-compose up -d
@ -63,11 +63,11 @@ dep ensure
затачиваем его под себя.
Redis можно установить в систему самостоятельно, но гораздо удобнее воспользоваться готовыми сервисами,
описанными в [docker-compose.dev.yml](docker-compose.dev.yml). Для этого просто копируем `docker-compose.dev.yml`
и поднимаем сервисы:
описанными в [docker/docker-compose.dev.yml](docker/docker-compose.dev.yml). Для этого просто копируем
`docker-compose.dev.yml` и поднимаем сервисы:
```sh
cp docker-compose.dev.yml docker-compose.yml
cp docker/docker-compose.dev.yml docker-compose.yml
docker-compose up -d
```

View File

@ -34,7 +34,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
viper.SetConfigName("config")
viper.AddConfigPath("/data")
viper.AddConfigPath("/etc/minecraft-skinsystem")
viper.AddConfigPath(".")
}

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

@ -3,7 +3,7 @@
#
# Usage:
# 1. Clone this file as docker-compose.yml:
# cp docker-compose.dev.yml 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:

View File

@ -9,6 +9,7 @@ services:
- redis
volumes:
- ./data/capes:/data/capes
- ./config/minecraft-skinsystem:/etc/minecraft-skinsystem
worker:
image: registry.ely.by/elyby/skinsystem:latest
@ -28,6 +29,6 @@ services:
image: rabbitmq:3.6-alpine
restart: always
environment:
RABBITMQ_DEFAULT_USER: "ely-skinsystem-app"
RABBITMQ_DEFAULT_PASS: "ely-skinsystem-app-password"
RABBITMQ_DEFAULT_VHOST: "/ely"
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 "$@"