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
|
||||
*.yml
|
||||
*file
|
||||
AGPL-3
|
||||
CC-BY-4.0
|
||||
CC-BY-SA-4.0
|
||||
COPYING
|
||||
*file
|
||||
elixir_buildpack.config
|
||||
test/
|
||||
test
|
||||
_build
|
||||
benchmarks
|
||||
ci
|
||||
deps
|
||||
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
|
||||
instance
|
||||
capture.pcap
|
||||
erl_crash.dump
|
||||
coveralls.json
|
||||
SIGNING_KEY.pub
|
||||
|
||||
# Required to get version
|
||||
!.git
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -79,3 +79,5 @@ docs/venv
|
|||
# docker stuff
|
||||
docker-db
|
||||
*.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 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" \
|
||||
org.opencontainers.image.description="Akkoma for Docker" \
|
||||
org.opencontainers.image.vendor="akkoma.dev" \
|
||||
org.opencontainers.image.documentation="https://docs.akkoma.dev/stable/" \
|
||||
org.opencontainers.image.licenses="AGPL-3.0" \
|
||||
org.opencontainers.image.url="https://akkoma.dev" \
|
||||
org.opencontainers.image.revision=$VCS_REF \
|
||||
org.opencontainers.image.created=$BUILD_DATE
|
||||
RUN addgroup -g ${GID} akkoma \
|
||||
&& adduser -u ${UID} -G akkoma -s /bin/sh -D akkoma \
|
||||
&& apk add --no-cache \
|
||||
git \
|
||||
gcc \
|
||||
g++ \
|
||||
musl-dev \
|
||||
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
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
ARG UNAME=akkoma
|
||||
ENTRYPOINT [ "docker-entrypoint.sh" ]
|
||||
|
||||
RUN addgroup -g $GID $UNAME
|
||||
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"]
|
||||
CMD [ "pleroma", "start" ]
|
||||
|
|
|
@ -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"
|
||||
|
||||
services:
|
||||
db:
|
||||
image: akkoma-db:latest
|
||||
build: ./docker-resources/database
|
||||
image: postgres:14-alpine
|
||||
restart: unless-stopped
|
||||
user: ${DOCKER_USER}
|
||||
environment: {
|
||||
# This might seem insecure but is usually not a problem.
|
||||
# You should leave this at the "akkoma" default.
|
||||
# The DB is only reachable by containers in the same docker network,
|
||||
# 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
|
||||
environment:
|
||||
POSTGRES_DB: akkoma
|
||||
POSTGRES_USER: akkoma
|
||||
POSTGRES_PASSWORD: akkoma
|
||||
# Comment out the volume below if you encounter any permission errors
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./pgdata
|
||||
target: /var/lib/postgresql/data
|
||||
- ./docker-db/:/var/lib/postgresql/data/:Z
|
||||
|
||||
akkoma:
|
||||
image: akkoma:latest
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
MIX_ENV: prod
|
||||
ERL_EPMD_ADDRESS: 127.0.0.1
|
||||
DB_NAME: akkoma
|
||||
DB_USER: akkoma
|
||||
DB_PASS: akkoma
|
||||
links:
|
||||
- db
|
||||
ports: [
|
||||
# Uncomment/Change port mappings below as needed.
|
||||
# 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",
|
||||
]
|
||||
ports:
|
||||
- "0.0.0.0:4000:4000"
|
||||
volumes:
|
||||
- .:/opt/akkoma
|
||||
|
||||
# Uncomment the following if you want to use a reverse proxy
|
||||
#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
|
||||
- ./static/:/var/lib/akkoma/static/:Z
|
||||
- ./uploads/:/var/lib/akkoma/uploads/:Z
|
||||
- ./etc/:/etc/akkoma/:Z
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
#!/bin/ash
|
||||
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "-- Waiting for database..."
|
||||
while ! pg_isready -U ${DB_USER:-pleroma} -d postgres://${DB_HOST:-db}:5432/${DB_NAME:-pleroma} -t 1; do
|
||||
if [ "$1" = 'pleroma' ] || [ "$1" = 'pleroma_ctl' ]; then
|
||||
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
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
echo "-- Running migrations..."
|
||||
mix ecto.migrate
|
||||
if [ "$1" = 'pleroma' ]; then
|
||||
echo "-- Running migrations..."
|
||||
pleroma_ctl migrate
|
||||
|
||||
echo "-- Starting!"
|
||||
mix phx.server
|
||||
echo "-- Starting!"
|
||||
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