Init repo

This commit is contained in:
Lukas Breuer 2018-04-07 22:29:55 +02:00
commit f17336caf3
9 changed files with 206 additions and 0 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
data

12
.env.dist Normal file
View File

@ -0,0 +1,12 @@
# The docker network to bind to.
# (Useful for reverse-proxies outside of this compose).
DOCKER_NETWORK=
# The directory where all containers store their data.
# Can be a relative path, "~/...", or absolute.
DOCKER_DATADIR=
# Database settings
POSTGRES_DB=
POSTGRES_USER=
POSTGRES_PASSWORD=

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
data
.env

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "pleroma"]
path = pleroma
url = git@git.pleroma.social:pleroma/pleroma.git
[submodule "camo"]
path = camo
url = https://github.com/atmos/camo.git

39
docker-compose.yml Normal file
View File

@ -0,0 +1,39 @@
version: "3"
networks:
default:
external:
name: ${DOCKER_NETWORK}
services:
db:
image: postgres:10.3-alpine
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- ${DOCKER_DATADIR}/db:/var/lib/postgresql/data
server:
build:
context: .
dockerfile: ./pleroma.dockerfile
restart: unless-stopped
links:
- db
environment:
POSTGRES_IP: db
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
PLEROMA_WORKSPACE: /pleroma
MIX_ARCHIVES: /mix/archives
MIX_HOME: /mix/home
volumes:
- ./pleroma:/pleroma
- ${DOCKER_DATADIR}/pleroma:/data
- ${DOCKER_DATADIR}/mix:/mix
- ${DOCKER_DATADIR}/misc/cache:/root/.cache
- ${DOCKER_DATADIR}/misc/meta:/meta

46
entrypoint.ash Executable file
View File

@ -0,0 +1,46 @@
#!/bin/ash
set -e
function action__build {
mix local.hex --force
mix local.rebar --force
mix deps.get
mix compile
}
function action__configure {
mix generate_config
}
function action__run {
if [[ ! -f /meta/ECTO_REPO_CREATED ]]; then
mix ecto.create
touch /meta/ECTO_REPO_CREATED
fi
mix ecto.migrate
exec mix phx.server
}
if [[ -z "$1" ]]; then
echo "No action provided."
exit 1
fi
if [[ -z "$PLEROMA_WORKSPACE" ]]; then
echo "Please set the PLEROMA_WORKSPACE variable to your pleroma root."
exit 1
fi
cd $PLEROMA_WORKSPACE
case "$1" in
build) action__build;;
configure) action__configure;;
run) action__run;;
*)
echo "The action '$1' is invalid."
exit 1
;;
esac
shift

1
pleroma Submodule

@ -0,0 +1 @@
Subproject commit 8f9bcc4ab0b16efa9168f49f6e2cc14bc424d398

10
pleroma.dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM elixir:1.6-alpine
RUN apk add --no-cache --virtual .build alpine-sdk git
ADD ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["run"]
EXPOSE 4000

89
pleroma.sh Executable file
View File

@ -0,0 +1,89 @@
#!/bin/bash
set -e
function log_generic { # $1: color, $2: prefix, $3: message #
echo -e "[$(tput setaf $1)$(tput bold)$2$(tput sgr0)] $3"
}
function log_error { # $1: message #
log_generic 1 ERR "$1"
}
function log_ok { # $1: message #
log_generic 2 "OK " "$1"
}
function log_info { # $1: message #
log_generic 4 INF "$1"
}
function print_help {
echo "
Pleroma Maintenance Script
Usage:
$0 [action] [flags...]
Actions:
build Build the pleroma container and all dependencies
configure Runs the interactive configuration script
run Start pleroma and sibling services
stop Stop pleroma and sibling services
"
}
function run_dockerized {
log_info "Stopping existing containers (if any)..."
docker-compose down
log_info "Rebuilding images..."
docker-compose build
log_info "Running action '$1'..."
docker-compose run server $1
log_info "Cleaning up.."
docker-compose down
}
function action__build {
run_dockerized "build"
log_ok "Done"
}
function action__configure {
run_dockerized "configure"
log_ok "Done"
}
function action__run {
log_info "Booting pleroma..."
docker-compose up --remove-orphans -d
log_ok "Done"
}
function action__stop {
log_info "Stopping pleroma..."
docker-compose down
log_ok "Done"
}
if [[ -z "$1" ]]; then
log_error "No action provided."
print_help
exit 1
fi
case "$1" in
build) action__build;;
configure) action__configure;;
run) action__run;;
stop) action__stop;;
*)
log_error "The action '$1' is invalid."
print_help
exit 1
;;
esac
shift