Skip to content

Commit

Permalink
Add initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
CSammy committed Apr 12, 2018
1 parent eafbd66 commit 0564c88
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
65 changes: 65 additions & 0 deletions Dockerfile.diaspora
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
FROM debian:stretch as base

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y -qq \
build-essential \
libssl-dev \
libcurl4-openssl-dev \
libxml2-dev \
libxslt-dev \
imagemagick \
ghostscript \
curl \
libmagickwand-dev \
git \
libpq-dev \
cmake \
nodejs \
# Packages for RVM
gawk \
libyaml-dev \
libsqlite3-dev \
sqlite3 \
autoconf \
libgmp-dev \
libgdbm-dev \
libncurses5-dev \
automake \
bison \
libffi-dev \
libgmp-dev \
libreadline-dev \
&& rm -rf /var/lib/apt/lists/*

ARG EXT_UID
ARG EXT_GID
RUN addgroup --system --gid ${EXT_GID} diaspora
RUN adduser --system --uid ${EXT_UID} --gid ${EXT_GID} diaspora

USER diaspora
RUN mkdir /home/diaspora/diaspora
WORKDIR /home/diaspora/diaspora

# Install RVM + Ruby
ENV LANG=C.UTF8

RUN curl -sSL https://rvm.io/mpapis.asc | gpg --import - \
&& curl -L https://s.diaspora.software/1t | bash \
&& rm -rf ~/.gnupg
SHELL ["/bin/bash", "--login", "-c"]

RUN rvm install 2.4

# Install bundler
RUN echo diaspora > .ruby-gemset \
&& echo 2.4 > .ruby-version \
&& touch Gemfile \
&& cd ../diaspora \
&& gem install bundler \
&& rm .ruby-* Gemfile

# Finish setup
COPY ./start.sh ../start.sh

CMD ["../start.sh"]
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# diaspora-docker
# diaspora-docker

This image is intended exclusively for development.

## Build And Run

1. Copy `example.env` to `.env`
1. Set `EXT_UID` and `EXT_GID` in `.env` according to your user's user and group ID
1. Execute `docker-compose build diaspora` (takes some time)
1. Copy or link your diaspora code to `./diaspora.docker`
1. Execute `docker-compose up`

- To restart, do `docker-compose restart diaspora` or (faster) `docker-compose exec diaspora /bin/bash --login -c "bin/eye restart diaspora"`
- To start without migrations and bundle install, set any value for `DIASPORA_DOCKER_DEV_INSTALL_GEMS` and `DIASPORA_DOCKER_DEV_DB_MIGRATE` in `.env`. It is only executed if these variables are empty

## TODO

- Control migrations and bundle installing more intuitively
- Create external script for controlling/handling the setup
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3"

volumes:
postgres_db:


services:

diaspora:
build:
context: .
dockerfile: Dockerfile.diaspora
args:
EXT_UID: "${EXT_UID}"
EXT_GID: "${EXT_GID}"
image: diaspora:dev-latest
environment:
DIASPORA_DOCKER_DEV_INSTALL_GEMS: "${DIASPORA_DOCKER_DEV_INSTALL_GEMS}"
DIASPORA_DOCKER_DEV_DB_MIGRATE: "${DIASPORA_DOCKER_DEV_DB_MIGRATE}"
ports:
- 8080:3000
volumes:
- ./diaspora.docker:/home/diaspora/diaspora:rw
depends_on:
- postgres
# - redis

postgres:
image: postgres:9.6
ports:
- 55432:5432
volumes:
- postgres_db:/var/lib/postgresql

# redis:
# image: redis:latest
4 changes: 4 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EXT_UID=1000
EXT_GID=1000
DIASPORA_DOCKER_DEV_INSTALL_GEMS=
DIASPORA_DOCKER_DEV_DB_MIGRATE=
19 changes: 19 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash --login

action_install_gems() {
script/configure_bundler
bin/bundle config --local path vendor/bundle
bin/bundle install --full-index
}

action_db_migrate() {
bin/rake db:create db:migrate
}

[ -z $DIASPORA_DOCKER_DEV_INSTALL_GEMS ] && action_install_gems

[ -z $DIASPORA_DOCKER_DEV_DB_MIGRATE ] && action_db_migrate

[ ! -f public/source.tar.gz ] && touch public/source.tar.gz

exec ./script/server

0 comments on commit 0564c88

Please sign in to comment.