full docker setup

This commit is contained in:
byte[] 2019-12-03 13:36:50 -05:00
parent 67c84a6933
commit de5868f5ad
6 changed files with 40 additions and 17 deletions

View file

@ -11,6 +11,7 @@ services:
environment: environment:
- MIX_ENV=dev - MIX_ENV=dev
working_dir: /srv/philomena working_dir: /srv/philomena
tty: true
volumes: volumes:
- .:/srv/philomena - .:/srv/philomena
depends_on: depends_on:
@ -38,7 +39,7 @@ services:
web: web:
build: build:
context: . context: .
dockerfile: ./docker/app/Dockerfile dockerfile: ./docker/web/Dockerfile
volumes: volumes:
- .:/srv/philomena - .:/srv/philomena
depends_on: depends_on:

View file

@ -3,21 +3,18 @@ FROM elixir:1.9.4
RUN apt-get update; \ RUN apt-get update; \
apt-get -qq -y install apt-transport-https; \ apt-get -qq -y install apt-transport-https; \
echo "deb https://deb.nodesource.com/node_12.x stretch main" >> /etc/apt/sources.list; \ echo "deb https://deb.nodesource.com/node_12.x stretch main" >> /etc/apt/sources.list; \
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list; \
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -; \
wget -qO - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \ wget -qO - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -; \
apt-get update; \ apt-get update; \
apt-get -qq -y install build-essential git ffmpeg nodejs libmagic-dev libpng-dev gifsicle optipng libjpeg-progs librsvg2-bin; \ apt-get -qq -y install inotify-tools postgresql-client build-essential git ffmpeg nodejs libmagic-dev libpng-dev gifsicle optipng libjpeg-progs librsvg2-bin; \
cd /tmp; \ cd /tmp; \
git clone https://github.com/derpibooru/cli_intensities; \ git clone https://github.com/derpibooru/cli_intensities; \
cd cli_intensities; \ cd cli_intensities; \
make install; \ make install; \
echo -e '#!/bin/sh\nrsvg-convert < "$1" -o "$2"\n' > /usr/local/bin/safe-rsvg-convert; \
chmod +x /usr/local/bin/safe-rsvg-convert
WORKDIR /srv/philomena
ADD . /srv/philomena
RUN cd /srv/philomena; \
mix local.hex --force; \ mix local.hex --force; \
mix deps.get; \ mix local.rebar --force
cd assets; \
npm install COPY docker/app/run-development /usr/local/bin/run-development
COPY docker/app/safe-rsvg-convert /usr/local/bin/safe-rsvg-convert
CMD run-development

24
docker/app/run-development Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# Always install assets
(cd /srv/philomena/assets && npm install)
# Always install mix dependencies
(cd /srv/philomena && mix deps.get)
# Sleep to allow Elasticsearch to finish initializing
# if it's not done doing whatever it does yet
echo -n "Waiting for Elasticsearch"
until wget -qO - localhost:9200; do
echo -n "."
sleep 2
done
echo
# Try to create the database if it doesn't exist yet
createdb -h localhost -U postgres philomena_dev && mix ecto.setup_dev
# Run the application
mix phx.server

2
docker/app/safe-rsvg-convert Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
rsvg-convert < "$1" -o "$2"

View file

@ -1,7 +1,6 @@
FROM nginx:1.17.6 FROM nginx:1.17.6
ENV APP_DIR /srv/philomena ENV APP_DIR /srv/philomena
WORKDIR $APP_DIR
COPY docker/web/nginx.conf /tmp/docker.nginx COPY docker/web/nginx.conf /tmp/docker.nginx
RUN envsubst '$APP_DIR' < /tmp/docker.nginx /etc/nginx/conf.d/default.conf RUN envsubst '$APP_DIR' < /tmp/docker.nginx > /etc/nginx/conf.d/default.conf
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View file

@ -33,9 +33,9 @@ defmodule Philomena.Servers.ImageProcessor do
defp process(image_id) do defp process(image_id) do
Philomena.Processors.process_image(image_id) Philomena.Processors.process_image(image_id)
#rescue rescue
# _ -> _ ->
# nil nil
end end
@impl true @impl true