Update Docker setup
This commit is contained in:
parent
f81f7def60
commit
84031ff4b3
10 changed files with 113 additions and 121 deletions
|
@ -1,17 +1,32 @@
|
||||||
.*
|
.*
|
||||||
*.md
|
*.md
|
||||||
|
*.yml
|
||||||
|
*file
|
||||||
AGPL-3
|
AGPL-3
|
||||||
|
CC-BY-4.0
|
||||||
CC-BY-SA-4.0
|
CC-BY-SA-4.0
|
||||||
COPYING
|
COPYING
|
||||||
*file
|
_build
|
||||||
elixir_buildpack.config
|
|
||||||
test/
|
|
||||||
test
|
|
||||||
benchmarks
|
benchmarks
|
||||||
|
ci
|
||||||
|
deps
|
||||||
docs/site
|
docs/site
|
||||||
docker-db
|
docs/venv
|
||||||
|
config/*.env
|
||||||
|
config/*.secret.exs
|
||||||
|
config/generated_config.exs
|
||||||
|
config/runtime.exs
|
||||||
|
config/setup_db*.psql
|
||||||
|
scripts
|
||||||
|
test
|
||||||
|
etc
|
||||||
|
static
|
||||||
uploads
|
uploads
|
||||||
instance
|
instance
|
||||||
|
capture.pcap
|
||||||
|
erl_crash.dump
|
||||||
|
coveralls.json
|
||||||
|
SIGNING_KEY.pub
|
||||||
|
|
||||||
# Required to get version
|
# Required to get version
|
||||||
!.git
|
!.git
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -79,3 +79,5 @@ docs/venv
|
||||||
# docker stuff
|
# docker stuff
|
||||||
docker-db
|
docker-db
|
||||||
*.iml
|
*.iml
|
||||||
|
static
|
||||||
|
etc
|
||||||
|
|
83
Dockerfile
83
Dockerfile
|
@ -1,34 +1,69 @@
|
||||||
FROM hexpm/elixir:1.15.2-erlang-26.0.2-alpine-3.17.4
|
FROM elixir:1.14-alpine as build
|
||||||
|
|
||||||
ENV MIX_ENV=prod
|
ENV MIX_ENV=prod
|
||||||
ENV ERL_EPMD_ADDRESS=127.0.0.1
|
ENV ERL_EPMD_ADDRESS=127.0.0.1
|
||||||
|
|
||||||
ARG HOME=/opt/akkoma
|
ARG BUILD_DIR=/opt/akkoma/
|
||||||
|
ARG UID=1000
|
||||||
|
ARG GID=1000
|
||||||
|
|
||||||
LABEL org.opencontainers.image.title="akkoma" \
|
RUN addgroup -g ${GID} akkoma \
|
||||||
org.opencontainers.image.description="Akkoma for Docker" \
|
&& adduser -u ${UID} -G akkoma -s /bin/sh -D akkoma \
|
||||||
org.opencontainers.image.vendor="akkoma.dev" \
|
&& apk add --no-cache \
|
||||||
org.opencontainers.image.documentation="https://docs.akkoma.dev/stable/" \
|
git \
|
||||||
org.opencontainers.image.licenses="AGPL-3.0" \
|
gcc \
|
||||||
org.opencontainers.image.url="https://akkoma.dev" \
|
g++ \
|
||||||
org.opencontainers.image.revision=$VCS_REF \
|
musl-dev \
|
||||||
org.opencontainers.image.created=$BUILD_DATE
|
make \
|
||||||
|
cmake \
|
||||||
|
file-dev
|
||||||
|
|
||||||
RUN apk add git gcc g++ musl-dev make cmake file-dev exiftool ffmpeg imagemagick libmagic ncurses postgresql-client
|
WORKDIR ${BUILD_DIR}
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN mkdir -p "${BUILD_DIR}_build/" \
|
||||||
|
&& mix local.hex --force \
|
||||||
|
&& mix local.rebar --force \
|
||||||
|
&& mix deps.get --only prod \
|
||||||
|
&& mix release --path "${BUILD_DIR}_build"
|
||||||
|
|
||||||
|
|
||||||
|
FROM elixir:1.14-alpine as web
|
||||||
|
|
||||||
|
ENV MIX_ENV=prod
|
||||||
|
ENV ERL_EPMD_ADDRESS=127.0.0.1
|
||||||
|
|
||||||
|
ARG DATA_DIR=/var/lib/akkoma/
|
||||||
|
ARG INSTALL_DIR=/opt/akkoma/
|
||||||
|
ARG CONFIG_DIR=/etc/akkoma/
|
||||||
|
ARG UID=1000
|
||||||
|
ARG GID=1000
|
||||||
|
|
||||||
|
RUN addgroup -g ${GID} akkoma \
|
||||||
|
&& adduser -u ${UID} -G akkoma -s /bin/sh -D akkoma \
|
||||||
|
&& apk add --no-cache \
|
||||||
|
exiftool \
|
||||||
|
ffmpeg \
|
||||||
|
imagemagick \
|
||||||
|
libmagic \
|
||||||
|
ncurses \
|
||||||
|
postgresql-client
|
||||||
|
|
||||||
|
RUN mkdir -p "${DATA_DIR}uploads/" \
|
||||||
|
&& mkdir -p "${DATA_DIR}static/" \
|
||||||
|
&& mkdir -p "${INSTALL_DIR}" \
|
||||||
|
&& mkdir -p "${CONFIG_DIR}"
|
||||||
|
|
||||||
|
COPY --from=build ${INSTALL_DIR}_build/ ${INSTALL_DIR}
|
||||||
|
COPY ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
|
ENV PATH="/opt/akkoma/bin:${PATH}"
|
||||||
|
|
||||||
|
WORKDIR ${INSTALL_DIR}
|
||||||
|
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|
||||||
ARG UID=1000
|
ENTRYPOINT [ "docker-entrypoint.sh" ]
|
||||||
ARG GID=1000
|
|
||||||
ARG UNAME=akkoma
|
|
||||||
|
|
||||||
RUN addgroup -g $GID $UNAME
|
CMD [ "pleroma", "start" ]
|
||||||
RUN adduser -u $UID -G $UNAME -D -h $HOME $UNAME
|
|
||||||
|
|
||||||
WORKDIR /opt/akkoma
|
|
||||||
|
|
||||||
USER $UNAME
|
|
||||||
RUN mix local.hex --force &&\
|
|
||||||
mix local.rebar --force
|
|
||||||
|
|
||||||
CMD ["/opt/akkoma/docker-entrypoint.sh"]
|
|
||||||
|
|
|
@ -1,61 +1,33 @@
|
||||||
|
# This file is for testing only, as I don't recommend using Docker Compose in a production environment
|
||||||
version: "3.7"
|
version: "3.7"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: akkoma-db:latest
|
image: postgres:14-alpine
|
||||||
build: ./docker-resources/database
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
user: ${DOCKER_USER}
|
environment:
|
||||||
environment: {
|
POSTGRES_DB: akkoma
|
||||||
# This might seem insecure but is usually not a problem.
|
POSTGRES_USER: akkoma
|
||||||
# You should leave this at the "akkoma" default.
|
POSTGRES_PASSWORD: akkoma
|
||||||
# The DB is only reachable by containers in the same docker network,
|
# Comment out the volume below if you encounter any permission errors
|
||||||
# and is not exposed to the open internet.
|
|
||||||
#
|
|
||||||
# If you do change this, remember to update "config.exs".
|
|
||||||
POSTGRES_DB: akkoma,
|
|
||||||
POSTGRES_USER: akkoma,
|
|
||||||
POSTGRES_PASSWORD: akkoma,
|
|
||||||
}
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
volumes:
|
volumes:
|
||||||
- type: bind
|
- ./docker-db/:/var/lib/postgresql/data/:Z
|
||||||
source: ./pgdata
|
|
||||||
target: /var/lib/postgresql/data
|
|
||||||
|
|
||||||
akkoma:
|
akkoma:
|
||||||
image: akkoma:latest
|
image: akkoma:latest
|
||||||
build: .
|
build: .
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
env_file:
|
environment:
|
||||||
- .env
|
MIX_ENV: prod
|
||||||
|
ERL_EPMD_ADDRESS: 127.0.0.1
|
||||||
|
DB_NAME: akkoma
|
||||||
|
DB_USER: akkoma
|
||||||
|
DB_PASS: akkoma
|
||||||
links:
|
links:
|
||||||
- db
|
- db
|
||||||
ports: [
|
ports:
|
||||||
# Uncomment/Change port mappings below as needed.
|
- "0.0.0.0:4000:4000"
|
||||||
# The left side is your host machine, the right one is the akkoma container.
|
|
||||||
# You can prefix the left side with an ip.
|
|
||||||
|
|
||||||
# Webserver (for reverse-proxies outside of docker)
|
|
||||||
# If you use a dockerized proxy, you can leave this commented
|
|
||||||
# and use a container link instead.
|
|
||||||
"127.0.0.1:4000:4000",
|
|
||||||
]
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/opt/akkoma
|
- ./static/:/var/lib/akkoma/static/:Z
|
||||||
|
- ./uploads/:/var/lib/akkoma/uploads/:Z
|
||||||
# Uncomment the following if you want to use a reverse proxy
|
- ./etc/:/etc/akkoma/:Z
|
||||||
#proxy:
|
|
||||||
# image: caddy:2-alpine
|
|
||||||
# restart: unless-stopped
|
|
||||||
# links:
|
|
||||||
# - akkoma
|
|
||||||
# ports: [
|
|
||||||
# "443:443",
|
|
||||||
# "80:80"
|
|
||||||
# ]
|
|
||||||
# volumes:
|
|
||||||
# - ./docker-resources/Caddyfile:/etc/caddy/Caddyfile
|
|
||||||
# - ./caddy-data:/data
|
|
||||||
# - ./caddy-config:/config
|
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
#!/bin/ash
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "-- Waiting for database..."
|
if [ "$1" = 'pleroma' ] || [ "$1" = 'pleroma_ctl' ]; then
|
||||||
while ! pg_isready -U ${DB_USER:-pleroma} -d postgres://${DB_HOST:-db}:5432/${DB_NAME:-pleroma} -t 1; do
|
echo "-- Waiting for database..."
|
||||||
|
while ! pg_isready -U "${DB_USER:-pleroma}" -d postgres://"${DB_HOST:-db}:5432/${DB_NAME:-pleroma}" -t 1; do
|
||||||
sleep 1s
|
sleep 1s
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "-- Running migrations..."
|
if [ "$1" = 'pleroma' ]; then
|
||||||
mix ecto.migrate
|
echo "-- Running migrations..."
|
||||||
|
pleroma_ctl migrate
|
||||||
|
|
||||||
echo "-- Starting!"
|
echo "-- Starting!"
|
||||||
mix phx.server
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
# default docker Caddyfile config for Akkoma
|
|
||||||
#
|
|
||||||
# Simple installation instructions:
|
|
||||||
# 1. Replace 'example.tld' with your instance's domain wherever it appears.
|
|
||||||
|
|
||||||
example.tld {
|
|
||||||
log {
|
|
||||||
output file /var/log/caddy/akkoma.log
|
|
||||||
}
|
|
||||||
|
|
||||||
encode gzip
|
|
||||||
|
|
||||||
reverse_proxy akkoma:4000
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) akkoma
|
|
||||||
docker compose build --build-arg UID=$(id -u) --build-arg GID=$(id -g) db
|
|
|
@ -1,10 +0,0 @@
|
||||||
FROM postgres:14-alpine
|
|
||||||
|
|
||||||
ARG UID=1000
|
|
||||||
ARG GID=1000
|
|
||||||
ARG UNAME=akkoma
|
|
||||||
|
|
||||||
RUN addgroup -g $GID $UNAME
|
|
||||||
RUN adduser -u $UID -G $UNAME -D -h $HOME $UNAME
|
|
||||||
|
|
||||||
USER akkoma
|
|
|
@ -1,5 +0,0 @@
|
||||||
MIX_ENV=prod
|
|
||||||
ERL_EPMD_ADDRESS=127.0.0.1
|
|
||||||
DB_NAME=akkoma
|
|
||||||
DB_USER=akkoma
|
|
||||||
DB_PASS=akkoma
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
docker compose run --rm akkoma $@
|
|
Loading…
Reference in a new issue