From acd0237facfce2550ccc3a5aaa0a028c40039147 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 16 Feb 2018 00:01:46 +0300 Subject: [PATCH] Update Dockerfile, add docker-compose for prod and dev environment, cleanup some old things --- .dockerignore | 3 --- .gitignore | 18 ++++-------------- Dockerfile | 12 ++++++++++++ config.dist.yml | 31 ------------------------------- docker-compose.dev.yml | 14 ++++++++++++++ docker-compose.prod.yml | 27 +++++++++++++++++++++++++++ docker-entrypoint.sh | 12 ++++++++++++ docker/Dockerfile | 13 ------------- docker/config.dist.yml | 31 ------------------------------- docker/docker-compose.dev.yml | 29 ----------------------------- docker/docker-compose.prod.yml | 18 ------------------ docker/docker-entrypoint.sh | 15 --------------- 12 files changed, 69 insertions(+), 154 deletions(-) create mode 100644 Dockerfile delete mode 100644 config.dist.yml create mode 100644 docker-compose.dev.yml create mode 100644 docker-compose.prod.yml create mode 100755 docker-entrypoint.sh delete mode 100644 docker/Dockerfile delete mode 100644 docker/config.dist.yml delete mode 100644 docker/docker-compose.dev.yml delete mode 100644 docker/docker-compose.prod.yml delete mode 100755 docker/docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore index eab7932..b9546b0 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,2 @@ -# Игнорим данные, т.к. они не нужны для внутреннего содержимого этого контейнера data - -# Vendor так же не нужен vendor diff --git a/.gitignore b/.gitignore index 55118de..efa479e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,5 @@ -# IDEA -/.idea - -# Docker Compose file -/docker-compose.yml -/docker-compose.override.yml - -# vendor -/vendor - -# Cover output +.idea +docker-compose.yml +docker-compose.override.yml +vendor .cover - -# Local config -/config.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eb83c07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:3.7 + +EXPOSE 80 + +ENV STORAGE_REDIS_HOST=redis +ENV STORAGE_FILESYSTEM_HOST=/data + +COPY docker-entrypoint.sh /usr/local/bin/ +COPY release/chrly /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["serve"] diff --git a/config.dist.yml b/config.dist.yml deleted file mode 100644 index ef890c7..0000000 --- a/config.dist.yml +++ /dev/null @@ -1,31 +0,0 @@ -# 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: localhost - port: 80 - -# 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: localhost - 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 - -# 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" diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..20e6f82 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,14 @@ +# This file can be used to start up necessary services. +# Copy it into the docker-compose.yml: +# > cp docker-compose.dev.yml docker-compose.yml +# And then run it: +# > docker-compose up -d + +version: '2' +services: + redis: + image: redis:4.0-32bit + ports: + - "6379:6379" + volumes: + - ./data/redis:/data diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..ca4e940 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,27 @@ +# This file can be used to run application in the production environment. +# Copy it into the docker-compose.yml: +# > cp docker-compose.prod.yml docker-compose.yml +# And then run it: +# > docker-compose up -d +# Service will be listened at the http://localhost + +version: '2' +services: + app: + image: elyby/chrly + hostname: chrly0 + restart: always + links: + - redis + volumes: + - ./data/capes:/data/capes + ports: + - "80:80" + environment: + CHRLY_SECRET: replace_this_value_in_production + + redis: + image: redis:4.0-32bit # 32-bit version is recommended to spare some memory + restart: always + volumes: + - ./data/redis:/data diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..de3fa34 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +if [ ! -d /data/capes ]; then + mkdir -p /data/capes +fi + +if [ "$1" = "serve" ] || [ "$1" = "token" ] || [ "$1" = "version" ]; then + set -- /usr/local/bin/chrly "$@" +fi + +exec "$@" diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index dc6d420..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM alpine:3.6 - -RUN apk --update add ca-certificates \ - && update-ca-certificates \ - && rm -rf /var/cache/apk/* - -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"] diff --git a/docker/config.dist.yml b/docker/config.dist.yml deleted file mode 100644 index 2827222..0000000 --- a/docker/config.dist.yml +++ /dev/null @@ -1,31 +0,0 @@ -# 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 - -# 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 - -# 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 diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml deleted file mode 100644 index 1533b4b..0000000 --- a/docker/docker-compose.dev.yml +++ /dev/null @@ -1,29 +0,0 @@ -# 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: -# 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 diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml deleted file mode 100644 index a94f397..0000000 --- a/docker/docker-compose.prod.yml +++ /dev/null @@ -1,18 +0,0 @@ -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 - - redis: - image: redis:3.2-32bit # 32-bit version used to decrease memory usage - restart: always - volumes: - - ./data/redis:/data diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh deleted file mode 100755 index 9382f91..0000000 --- a/docker/docker-entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/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" = "token" ] || [ "$1" = "version" ]; then - set -- minecraft-skinsystem "$@" -fi - -exec "$@"