Browse Source

Initial dockerfile setup and blanked out docker-compose files

staging
David Ludwig 4 years ago
parent
commit
0e01a95c94
4 changed files with 266 additions and 179 deletions
  1. +87
    -0
      Dockerfile
  2. +36
    -36
      docker-compose.dev.yml
  3. +20
    -20
      docker-compose.prod.yml
  4. +123
    -123
      docker-compose.yml

+ 87
- 0
Dockerfile View File

@ -0,0 +1,87 @@
# --------------------------------------------------------------------------------------------------
# NOTE: This Dockerfile was designed to be run with BuildKit.
#
# Enable BuildKit using:
# $ export DOCKER_BUILDKIT=1
# $ export COMPOSE_DOCKER_CLI_BUILD=1
# --------------------------------------------------------------------------------------------------
# The service to build
ARG SERVICE
# The base image to use
ARG BASE=base-alpine
# Base Definitions ---------------------------------------------------------------------------------
# Alpine base definition
FROM node:14-alpine AS base-alpine
# Alpine dev definition
FROM base-alpine AS base-alpine-dev
RUN apk add build-base python3
# Slim base definition
FROM node:14-slim AS base-slim
# Slim dev definition
FROM base-slim AS base-slim-dev
# Development Image --------------------------------------------------------------------------------
# Define the base image
FROM ${BASE}-dev AS dev
ARG SERVICE
WORKDIR /opt/app
# Environment configuration
ENV PATH "/app/node_modules/.bin:$PATH"
RUN echo "#!/bin/sh" >> /bin/lerna && \
echo '( cd /opt/app && ./node_modules/.bin/lerna "$@" )' >> /bin/lerna && \
chmod +x /bin/lerna
# Copy over Lerna stuff
COPY lerna.json package.json tsconfig.json ./
RUN yarn install
# Symlink the requested service to /app
RUN ln -s /opt/app/services/${SERVICE} /app
WORKDIR /app
# Build Definitions --------------------------------------------------------------------------------
# Create the builder image with all dependencies
FROM ${BASE}-dev AS builder
ARG SERVICE
WORKDIR /app
RUN yarn global add lerna typescript rimraf
COPY scripts scripts
COPY lerna.json package.json tsconfig.json yarn.lock ./
RUN yarn install
COPY packages packages
COPY services/${SERVICE}/package.json ./services/${SERVICE}/
# Cache an image containing only the prod-dependencies
FROM builder AS prod-deps
RUN lerna bootstrap -- --production --no-optional
RUN yarn run export:deps
# Build the service
FROM builder AS build
ARG SERVICE
COPY services/${SERVICE} ./services/${SERVICE}
RUN lerna clean --yes && lerna bootstrap && lerna run clean && lerna run build
RUN yarn run export:builds
# Return to base image with the compiled files and production dependencies
FROM ${BASE} AS prod
ARG SERVICE
WORKDIR /app
COPY --from=prod-deps /app/build /opt
COPY --from=build /app/build /opt
RUN for link in $(find /opt/services -type l); do dir=$(readlink -f $link); rm $link; ln -s $dir $link; done
RUN mv /opt/services/${SERVICE}/* /app && rm -rf /opt/services
# TODO: Should remove unnecessary packages that were included
# Default entrypoint
ENTRYPOINT "/bin/sh"

+ 36
- 36
docker-compose.dev.yml View File

@ -1,45 +1,45 @@
version: "3.9"
services:
request:
build:
target: base
ports:
- 3001:3001
volumes:
- ./request:/app
entrypoint: "/bin/sh"
tty: true
# request:
# build:
# target: base
# ports:
# - 3001:3001
# volumes:
# - ./request:/app
# entrypoint: "/bin/sh"
# tty: true
seeker:
build:
target: base-dev
volumes:
- ./seeker:/app
entrypoint: "/bin/sh"
tty: true
# seeker:
# build:
# target: base-dev
# volumes:
# - ./seeker:/app
# entrypoint: "/bin/sh"
# tty: true
torrent_webui:
build:
target: base
ports:
- 3000:3000
volumes:
- ./torrent-webui:/app
entrypoint: "/bin/sh"
tty: true
# torrent_webui:
# build:
# target: base
# ports:
# - 3000:3000
# volumes:
# - ./torrent-webui:/app
# entrypoint: "/bin/sh"
# tty: true
torrent_client:
build:
target: base
volumes:
- ./torrent-client:/app
# ulimits:
# core:
# hard: -1
# soft: -1
entrypoint: "/bin/sh"
tty: true
# torrent_client:
# build:
# target: base
# volumes:
# - ./torrent-client:/app
# # ulimits:
# # core:
# # hard: -1
# # soft: -1
# entrypoint: "/bin/sh"
# tty: true
# torrent_client:
# build:


+ 20
- 20
docker-compose.prod.yml View File

@ -1,26 +1,26 @@
version: "3.9"
services:
request:
build:
target: prod
environment:
NODE_ENV: production
# request:
# build:
# target: prod
# environment:
# NODE_ENV: production
seeker:
build:
target: prod
environment:
NODE_ENV: production
# seeker:
# build:
# target: prod
# environment:
# NODE_ENV: production
torrent_webui:
build:
target: prod
environment:
NODE_ENV: production
# torrent_webui:
# build:
# target: prod
# environment:
# NODE_ENV: production
torrent_client:
build:
target: prod
environment:
NODE_ENV: production
# torrent_client:
# build:
# target: prod
# environment:
# NODE_ENV: production

+ 123
- 123
docker-compose.yml View File

@ -1,90 +1,90 @@
version: "3.9"
services:
request:
build:
context: ./request
depends_on:
- "database"
- "torrent_client"
env_file:
- ./request/.env
links:
- "database"
- "torrent_client"
ports:
- 3200:3200
restart: unless-stopped
secrets:
- app_key
- discord_bot_key
- mysql_root_password
- plex_token
- tmdb_key
- tvdb_key
- tvdb_pin
user: ${UID}:${GID}
volumes:
- var:/var/autoplex
# request:
# build:
# context: ./request
# depends_on:
# - "database"
# - "torrent_client"
# env_file:
# - ./request/.env
# links:
# - "database"
# - "torrent_client"
# ports:
# - 3200:3200
# restart: unless-stopped
# secrets:
# - app_key
# - discord_bot_key
# - mysql_root_password
# - plex_token
# - tmdb_key
# - tvdb_key
# - tvdb_pin
# user: ${UID}:${GID}
# volumes:
# - var:/var/autoplex
seeker:
build:
context: ./seeker
depends_on:
- "database"
- "torrent_client"
env_file:
- ./seeker/.env
links:
- "database"
- "torrent_client"
restart: unless-stopped
secrets:
- mysql_root_password
user: ${UID}:${GID}
volumes:
- var:/var/autoplex
# seeker:
# build:
# context: ./seeker
# depends_on:
# - "database"
# - "torrent_client"
# env_file:
# - ./seeker/.env
# links:
# - "database"
# - "torrent_client"
# restart: unless-stopped
# secrets:
# - mysql_root_password
# user: ${UID}:${GID}
# volumes:
# - var:/var/autoplex
torrent_webui:
build:
context: ./torrent-webui
depends_on:
- "database"
- "torrent_client"
env_file:
- ./torrent-webui/.env
links:
- "database"
- "torrent_client"
ports:
- 3300:3300
secrets:
- mysql_root_password
user: ${UID}:${GID}
volumes:
- var:/var/autoplex
# torrent_webui:
# build:
# context: ./torrent-webui
# depends_on:
# - "database"
# - "torrent_client"
# env_file:
# - ./torrent-webui/.env
# links:
# - "database"
# - "torrent_client"
# ports:
# - 3300:3300
# secrets:
# - mysql_root_password
# user: ${UID}:${GID}
# volumes:
# - var:/var/autoplex
torrent_client:
build:
context: ./torrent-client
depends_on:
- "database"
- "vpn"
env_file:
- ./torrent-client/.env
healthcheck:
test: ["CMD", "ping", "-q", "-c1", "google.com"]
interval: 5m
timeout: 10s
retries: 3
start_period: 5m
network_mode: service:vpn
restart: unless-stopped
secrets:
- mysql_root_password
user: ${UID}:${GID}
volumes:
- var:/var/autoplex
# torrent_client:
# build:
# context: ./torrent-client
# depends_on:
# - "database"
# - "vpn"
# env_file:
# - ./torrent-client/.env
# healthcheck:
# test: ["CMD", "ping", "-q", "-c1", "google.com"]
# interval: 5m
# timeout: 10s
# retries: 3
# start_period: 5m
# network_mode: service:vpn
# restart: unless-stopped
# secrets:
# - mysql_root_password
# user: ${UID}:${GID}
# volumes:
# - var:/var/autoplex
# torrent_client:
# build:
@ -106,49 +106,49 @@ services:
# - ./.volumes/storage:/storage/default
# - var:/var/autoplex
database:
image: mysql
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/mysql_root_password
ports:
- 33061:3306
restart: unless-stopped
security_opt:
- seccomp=unconfined
secrets:
- mysql_root_password
volumes:
- ./database/init:/docker-entrypoint-initdb.d
- mysql:/var/lib/mysql
# database:
# image: mysql
# command: --default-authentication-plugin=mysql_native_password
# environment:
# MYSQL_ROOT_PASSWORD_FILE: /run/secrets/mysql_root_password
# ports:
# - 33061:3306
# restart: unless-stopped
# security_opt:
# - seccomp=unconfined
# secrets:
# - mysql_root_password
# volumes:
# - ./database/init:/docker-entrypoint-initdb.d
# - mysql:/var/lib/mysql
vpn:
build:
context: ./vpn
cap_add:
- net_admin
command:
- '-f ""'
environment:
TZ: "CST6CDT"
links:
- "database"
networks:
- default
read_only: true
tmpfs:
- /run
- /tmp
restart: unless-stopped
secrets:
- vpn_auth
security_opt:
- label:disable
stdin_open: true
tty: true
volumes:
- /dev/net:/dev/net:z
- ./.volumes/vpn:/vpn
# vpn:
# build:
# context: ./vpn
# cap_add:
# - net_admin
# command:
# - '-f ""'
# environment:
# TZ: "CST6CDT"
# links:
# - "database"
# networks:
# - default
# read_only: true
# tmpfs:
# - /run
# - /tmp
# restart: unless-stopped
# secrets:
# - vpn_auth
# security_opt:
# - label:disable
# stdin_open: true
# tty: true
# volumes:
# - /dev/net:/dev/net:z
# - ./.volumes/vpn:/vpn
secrets:
app_key:


Loading…
Cancel
Save