forked from e621ng/e621ng
[Setup] Improve docker setup
* Reduces the image size by using alpine and cleaning up after some things * Simplify the initial setup instructions slightly * Access via localhost:3000 instead of e621.local
This commit is contained in:
parent
9bdae110e7
commit
ce871e412c
89
Dockerfile
89
Dockerfile
@ -1,65 +1,68 @@
|
||||
FROM ruby:2.7.3
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y gnupg2 wget
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y gnupg2 wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Add custom sources
|
||||
RUN wget -qO - https://deb.nodesource.com/setup_14.x | bash - >/dev/null 2>&1
|
||||
RUN wget -qO - https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
|
||||
RUN wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
||||
RUN echo "deb https://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
RUN wget -qO - https://deb.nodesource.com/setup_14.x | bash - >/dev/null 2>&1 \
|
||||
&& wget -qO - https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
|
||||
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
|
||||
&& wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
|
||||
&& echo "deb https://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y ffmpeg postgresql-client-12 nodejs yarn nginx build-essential pkg-config sudo
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y ffmpeg postgresql-client-12 nodejs yarn nginx build-essential pkg-config sudo nano \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# User setup
|
||||
RUN useradd -m -s /bin/bash -U danbooru
|
||||
RUN usermod -aG www-data danbooru
|
||||
RUN echo "%danbooru ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/danbooru
|
||||
RUN useradd -m -s /bin/bash -U danbooru \
|
||||
&& usermod -aG www-data danbooru \
|
||||
&& echo "%danbooru ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/danbooru
|
||||
|
||||
# libvips
|
||||
RUN apt-get install -y libglib2.0-dev libexpat1-dev liblcms2-dev \
|
||||
optipng libjpeg62-turbo-dev libjpeg-progs libgif-dev libpng-dev libexif-dev
|
||||
ARG VIPS_DEPS="libglib2.0-dev libexpat1-dev liblcms2-dev optipng libjpeg62-turbo-dev libjpeg-progs libgif-dev libpng-dev libexif-dev"
|
||||
ARG VIPS_VERSION=8.10.5
|
||||
WORKDIR /tmp
|
||||
RUN wget -q https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz
|
||||
RUN tar xf vips-$VIPS_VERSION.tar.gz
|
||||
WORKDIR /tmp/vips-$VIPS_VERSION
|
||||
RUN ./configure --prefix=/usr
|
||||
RUN make install
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y $VIPS_DEPS \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& cd /tmp \
|
||||
&& wget -q https://github.com/libvips/libvips/releases/download/v$VIPS_VERSION/vips-$VIPS_VERSION.tar.gz \
|
||||
&& tar xf vips-$VIPS_VERSION.tar.gz \
|
||||
&& cd vips-$VIPS_VERSION \
|
||||
&& ./configure --prefix=/usr \
|
||||
&& make install \
|
||||
&& rm /tmp/vips-$VIPS_VERSION.tar.gz \
|
||||
&& rm -rf /tmp/vips-$VIPS_VERSION
|
||||
|
||||
# shoreman
|
||||
RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh
|
||||
RUN chmod +x /usr/bin/shoreman
|
||||
RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \
|
||||
&& chmod +x /usr/bin/shoreman
|
||||
|
||||
# prevent permission issues with volume mounts
|
||||
RUN mkdir /app
|
||||
RUN chown danbooru:danbooru /app
|
||||
RUN mkdir /app/public
|
||||
RUN chown danbooru:danbooru /app/public
|
||||
|
||||
RUN mkdir /app/node_modules
|
||||
RUN mkdir /app/public/packs
|
||||
RUN mkdir /app/public/packs-test
|
||||
RUN mkdir /app/public/data
|
||||
|
||||
RUN chown danbooru:danbooru /app/node_modules
|
||||
RUN chown danbooru:danbooru /app/public/packs
|
||||
RUN chown danbooru:danbooru /app/public/packs-test
|
||||
RUN chown danbooru:danbooru /app/public/data
|
||||
|
||||
RUN mkdir /home/danbooru/gems
|
||||
RUN chown danbooru:danbooru /home/danbooru/gems
|
||||
RUN mkdir /app \
|
||||
&& chown danbooru:danbooru /app \
|
||||
&& mkdir /app/public \
|
||||
&& chown danbooru:danbooru /app/public \
|
||||
&& mkdir /app/node_modules \
|
||||
&& mkdir /app/public/packs \
|
||||
&& mkdir /app/public/packs-test \
|
||||
&& mkdir /app/public/data \
|
||||
&& chown danbooru:danbooru /app/node_modules \
|
||||
&& chown danbooru:danbooru /app/public/packs \
|
||||
&& chown danbooru:danbooru /app/public/packs-test \
|
||||
&& chown danbooru:danbooru /app/public/data \
|
||||
&& mkdir /home/danbooru/gems \
|
||||
&& chown danbooru:danbooru /home/danbooru/gems
|
||||
|
||||
USER danbooru
|
||||
|
||||
# Setup secrets
|
||||
RUN mkdir -p ~/.danbooru/
|
||||
RUN openssl rand -hex 32 > ~/.danbooru/secret_token
|
||||
RUN openssl rand -hex 32 > ~/.danbooru/session_secret_key
|
||||
RUN chmod 600 ~/.danbooru/*
|
||||
RUN mkdir -p ~/.danbooru/ \
|
||||
&& openssl rand -hex 32 > ~/.danbooru/secret_token \
|
||||
&& openssl rand -hex 32 > ~/.danbooru/session_secret_key \
|
||||
&& chmod 600 ~/.danbooru/*
|
||||
|
||||
WORKDIR /app
|
||||
CMD [ "shoreman" ]
|
||||
|
@ -13,17 +13,13 @@
|
||||
3. `cd` into the repo.
|
||||
4. Run the following commands:
|
||||
```
|
||||
docker-compose build
|
||||
docker-compose run e621 dropdb danbooru2 -h postgres
|
||||
docker-compose run e621 /app/bin/setup
|
||||
docker-compose up
|
||||
```
|
||||
After running the commands once only `docker-compose up` is needed to bring up the containers.
|
||||
5. Add the following to your host file:
|
||||
`192.168.64.78 e621.local`
|
||||
5. This would be a good time to rewatch your favorite TV series installment, cook & have breakfast/lunch/dinner, walk the dog, clean your room, etc.<br>
|
||||
By the time you get back the install will surely have completed.<sup>1</sup>
|
||||
6. To confirm the installation worked, open the web browser of your choice and enter `http://e621.local` into the address bar and see if the website loads correctly.
|
||||
6. To confirm the installation worked, open the web browser of your choice and enter `http://localhost:3000` into the address bar and see if the website loads correctly.
|
||||
|
||||
<sub><sup>1</sup> If the install did not finish by the time an activity is complete please select another activity to avoid crippling boredom.</sub>
|
||||
|
||||
|
@ -161,7 +161,7 @@ fart'
|
||||
|
||||
# List of memcached servers
|
||||
def memcached_servers
|
||||
%w(memcached:11211)
|
||||
%w(127.0.0.1:11211)
|
||||
end
|
||||
|
||||
def alias_implication_forum_category
|
||||
@ -926,7 +926,7 @@ fart'
|
||||
end
|
||||
|
||||
def elasticsearch_host
|
||||
'elastic'
|
||||
'127.0.0.1'
|
||||
end
|
||||
|
||||
# Use a recaptcha on the signup page to protect against spambots creating new accounts.
|
||||
@ -970,7 +970,6 @@ fart'
|
||||
end
|
||||
|
||||
def redis_url
|
||||
"redis://redis"
|
||||
end
|
||||
|
||||
def bypass_upload_whitelist?(user)
|
||||
|
@ -61,8 +61,4 @@ Rails.application.configure do
|
||||
|
||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||
# config.action_cable.disable_request_forgery_protection = true
|
||||
|
||||
config.hosts << 'e621ng.local'
|
||||
config.hosts << 'e621.local'
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: "2.4"
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
e621:
|
||||
@ -7,13 +7,17 @@ services:
|
||||
- .:/app
|
||||
- node_modules:/app/node_modules
|
||||
- public_packs:/app/public/packs
|
||||
- public_packs:/app/public/packs-test
|
||||
- public_packs_test:/app/public/packs-test
|
||||
- post_data:/app/public/data
|
||||
- gems:/home/danbooru/gems
|
||||
environment:
|
||||
DATABASE_URL: postgresql://postgres
|
||||
RAILS_ENV: development
|
||||
GEM_HOME: /home/danbooru/gems
|
||||
DANBOORU_HOSTNAME: http://localhost:3000
|
||||
DANBOORU_REDIS_URL: redis://redis
|
||||
DANBOORU_ELASTICSEARCH_HOST: elastic
|
||||
DANBOORU_MEMCACHED_SERVERS: memcached
|
||||
depends_on:
|
||||
- postgres
|
||||
- redis
|
||||
@ -21,26 +25,25 @@ services:
|
||||
- elastic
|
||||
|
||||
nginx:
|
||||
image: nginx:stable
|
||||
image: nginx:stable-alpine
|
||||
volumes:
|
||||
- ./public:/app/public
|
||||
- post_data:/app/public/data
|
||||
- public_packs:/app/public/packs
|
||||
- public_packs:/app/public/packs-test
|
||||
- public_packs_test:/app/public/packs-test
|
||||
- ./docker/default.conf.template:/etc/nginx/templates/default.conf.template
|
||||
environment:
|
||||
NGINX_HOST: e621.local
|
||||
NGINX_HOST: localhost
|
||||
NGINX_PORT: 3000
|
||||
depends_on:
|
||||
- e621
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 192.168.64.78
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
postgres:
|
||||
build: ./docker/postgres
|
||||
environment:
|
||||
- POSTGRES_USER=danbooru
|
||||
- POSTGRES_DB=danbooru2
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
@ -48,34 +51,25 @@ services:
|
||||
- "34517:5432"
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
image: redis:alpine
|
||||
|
||||
memcached:
|
||||
image: memcached:latest
|
||||
image: memcached:alpine
|
||||
|
||||
elastic:
|
||||
image: elasticsearch:7.14.2
|
||||
mem_limit: 1gb
|
||||
environment:
|
||||
- discovery.type=single-node
|
||||
- xpack.security.enabled=false
|
||||
- ES_JAVA_OPTS=-Xms1g -Xmx1g
|
||||
volumes:
|
||||
- elastic_data:/usr/share/elasticsearch/data
|
||||
|
||||
volumes:
|
||||
gems:
|
||||
db_data:
|
||||
elastic_data:
|
||||
node_modules:
|
||||
post_data:
|
||||
elastic_data:
|
||||
db_data:
|
||||
gems:
|
||||
node_modules:
|
||||
public_packs:
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: e621
|
||||
driver: bridge
|
||||
ipam:
|
||||
driver: default
|
||||
config:
|
||||
- subnet: 192.168.64.0/24
|
||||
gateway: 192.168.64.1
|
||||
public_packs_test:
|
||||
|
@ -1,5 +1,5 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen ${NGINX_PORT};
|
||||
server_name ${NGINX_HOST};
|
||||
root /app/public;
|
||||
index index.html;
|
||||
@ -36,10 +36,11 @@ server {
|
||||
|
||||
location @app_server {
|
||||
proxy_pass http://app_server;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_redirect off;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $host:$server_port;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
FROM postgres:12
|
||||
ARG BUILD_DEPS="git build-essential make postgresql-server-dev-12 ca-certificates"
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y git build-essential postgresql-server-dev-12
|
||||
RUN git clone https://github.com/r888888888/test_parser.git /tmp/test_parser
|
||||
RUN make -C /tmp/test_parser install
|
||||
RUN apt-get update && apt-get install -y $BUILD_DEPS --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& git clone https://github.com/r888888888/test_parser.git /tmp/test_parser \
|
||||
&& cd /tmp/test_parser \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/test_parser \
|
||||
&& apt-get purge -y --auto-remove $BUILD_DEPS
|
||||
|
Loading…
Reference in New Issue
Block a user