Unverified Commit dae1717d authored by CSammy's avatar CSammy Committed by Dennis Schubert

Add docker setup for development

closes #7870
parent 0133a9f3
......@@ -2,6 +2,8 @@
## Refactor
* Make setting up a development environment 9001% easier by adding a Docker-based setup [#7870](https://github.com/diaspora/diaspora/pull/7870)
## Bug fixes
## Features
......
FROM ruby:2.4.4-slim-stretch
RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install -y -qq \
build-essential \
cmake \
curl \
ghostscript \
git \
imagemagick \
libcurl4-openssl-dev \
libidn11-dev \
libmagickwand-dev \
libmariadbclient-dev \
libpq-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
nodejs \
gosu \
&& \
rm -rf /var/lib/apt/lists/*
ARG DIA_UID
ARG DIA_GID
ENV HOME="/home/diaspora" \
GEM_HOME="/diaspora/vendor/bundle"
RUN addgroup --gid $DIA_GID diaspora && \
adduser \
--no-create-home \
--disabled-password \
--gecos "" \
--uid $DIA_UID \
--gid $DIA_GID \
diaspora \
&& \
mkdir $HOME /diaspora && \
chown -R diaspora:diaspora $HOME /diaspora
RUN curl -L \
https://cifiles.diasporafoundation.org/phantomjs-2.1.1-linux-x86_64.tar.bz2 \
| tar -xj -C /usr/local/bin \
--transform='s#.*/##' \
phantomjs-2.1.1-linux-x86_64/bin/phantomjs
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_BIN="$GEM_HOME/bin" \
BUNDLE_APP_CONFIG="/diaspora/.bundle"
ENV PATH $BUNDLE_BIN:$PATH
COPY docker-entrypoint.sh /entrypoint.sh
COPY docker-exec-entrypoint.sh /exec-entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./script/server"]
version: "3.4"
volumes:
postgresql_data:
mysql_data:
dia_data_tmp:
dia_data_bundle:
services:
diaspora:
build:
context: .
dockerfile: Dockerfile
args:
DIA_UID: "${DIASPORA_ROOT_UID}"
DIA_GID: "${DIASPORA_ROOT_GID}"
image: diaspora:dev-latest
volumes:
- "${DIASPORA_ROOT}:/diaspora:rw"
- dia_data_tmp:/diaspora/tmp
- dia_data_bundle:/diaspora/vendor/bundle
ports:
- 8080:3000
depends_on:
- "${DIASPORA_DOCKER_DB}"
postgresql:
image: postgres:10.3
ports:
- 55432:5432
volumes:
- postgresql_data:/var/lib/postgresql
mysql:
image: mariadb:10.2
ports:
- 53306:3306
volumes:
- mysql_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: mysql
#!/bin/bash
# ----- Ensure correct ownership of /diaspora -----
dia_home=/home/diaspora
HOST_UID=$(stat -c %u /diaspora)
HOST_GID=$(stat -c %g /diaspora)
if ! getent group $HOST_GID >/dev/null; then
groupmod --gid $HOST_GID diaspora
fi
if ! getent passwd $HOST_UID >/dev/null; then
usermod --uid $HOST_UID --gid $HOST_GID diaspora
fi
chown -R $HOST_UID:$HOST_GID /home/diaspora
mkdir -p /diaspora/tmp/pids
chown $HOST_UID:$HOST_GID /diaspora/tmp /diaspora/tmp/pids /diaspora/vendor/bundle
# ----- Wait for DB ----
if [ -z $DIA_NODB ] || [ ! $DIA_NODB -eq 1 ]; then
if grep -qFx " <<: *postgresql" /diaspora/config/database.yml; then
host=postgresql
port=5432
else
host=mysql
port=3306
fi
c=0
trap '{ exit 1; }' INT
while ! (< /dev/tcp/${host}/${port}) 2>/dev/null; do
printf "\rWaiting for $host:$port to become ready ... ${c}s"
sleep 1
((c++))
done
trap - INT
if [ ! -z $c ]; then
printf "\rWaiting for $host:$port to become ready ... done (${c}s)\n"
fi
fi
cd /diaspora
gosu $HOST_UID:$HOST_GID "$@"
#!/bin/bash
HOST_UID=$(stat -c %u /diaspora)
HOST_GID=$(stat -c %g /diaspora)
cd /diaspora
gosu $HOST_UID:$HOST_GID "$@"
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment