Start work on masto container
This commit is contained in:
parent
5bceb10e38
commit
52b2d9173d
48
mastodon/Dockerfile.arm64v8
Normal file
48
mastodon/Dockerfile.arm64v8
Normal file
|
@ -0,0 +1,48 @@
|
|||
FROM arm64v8/ruby:2.7-alpine
|
||||
|
||||
# Set up git remote
|
||||
ARG TAG
|
||||
ARG GIT_REPOSITORY
|
||||
ARG BUILD_DATE
|
||||
|
||||
# Tell rails to serve static files
|
||||
ENV RAILS_SERVE_STATIC_FILES="true"
|
||||
ENV RAILS_ENV="production"
|
||||
ENV NODE_ENV="production"
|
||||
|
||||
# Install helper scripts
|
||||
COPY root/ /
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache whois nodejs yarn ca-certificates git bash \
|
||||
gcc g++ make libc-dev file sed \
|
||||
imagemagick protobuf-dev libpq ffmpeg icu-dev libidn-dev yaml-dev \
|
||||
readline-dev postgresql-dev curl tini && \
|
||||
update-ca-certificates
|
||||
|
||||
# Create the mastodon user
|
||||
ARG UID=1001
|
||||
ARG GID=1001
|
||||
RUN echo "Etc/UTC" > /etc/localtime && \
|
||||
addgroup --gid $GID mastodon && \
|
||||
adduser -D -u 991 -G mastodon -h /opt/mastodon mastodon && \
|
||||
echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd && \
|
||||
chown -R mastodon:mastodon /opt
|
||||
|
||||
# Install mastodon
|
||||
USER mastodon
|
||||
RUN git clone -b ${TAG} ${GIT_REPOSITORY} /opt/mastodon && \
|
||||
rm -rf /opt/mastodon/.git
|
||||
|
||||
# Install dependencies
|
||||
WORKDIR /opt/mastodon
|
||||
RUN bundle config set deployment 'true' && \
|
||||
bundle install -j$(nproc) --without development test --with production && \
|
||||
yarn install --pure-lockfile && \
|
||||
yarn cache clean
|
||||
|
||||
# Compile assets
|
||||
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder \
|
||||
bundle exec rake assets:precompile
|
||||
|
||||
ENTRYPOINT ["/sbin/tini", "--"]
|
57
mastodon/build.sh
Executable file
57
mastodon/build.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
DEFAULT_TAG=asonix/downstream
|
||||
DEFAULT_REPOSITORY=https://git.asonix.dog/asonix/mastodon
|
||||
|
||||
BUILD_DATE=$(date)
|
||||
VERSION=$1
|
||||
TAG=${2:-$DEFAULT_TAG}
|
||||
GIT_REPOSITORY=${3:-$DEFAULT_REPOSITORY}
|
||||
|
||||
function require() {
|
||||
if [ "$1" = "" ]; then
|
||||
echo "input '$2' required"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function print_help() {
|
||||
echo "build.sh"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " build.sh [version] [tag] [repository]"
|
||||
echo ""
|
||||
echo "Args:"
|
||||
echo " version: The version of the current container"
|
||||
echo " tag: The tag or branch of mastodon to include (optional, defaults to asonix/downstream)"
|
||||
echo " repository: The git repository to fetch mastodon from (optional, defaults to https://git.asonix.dog/asonix/mastodon)"
|
||||
}
|
||||
|
||||
function build_image() {
|
||||
IMAGE=$1
|
||||
ARCH=$2
|
||||
|
||||
docker build \
|
||||
--pull \
|
||||
--no-cache \
|
||||
--build-arg BUILD_DATE="${BUILD_DATE}" \
|
||||
--build-arg TAG="${TAG}" \
|
||||
--build-arg VERSION="${VERSION}" \
|
||||
--build-arg GIT_REPOSITORY="${GIT_REPOSITORY}" \
|
||||
-f "Dockerfile.${ARCH}" \
|
||||
-t "${IMAGE}:$(echo ${TAG} | sed 's/\//-/g')-${VERSION}-${ARCH}" \
|
||||
-t "${IMAGE}:latest-${ARCH}" \
|
||||
-t "${IMAGE}:latest" \
|
||||
.
|
||||
|
||||
docker push "${IMAGE}:${TAG}-${VERSION}-${ARCH}"
|
||||
docker push "${IMAGE}:latest-${ARCH}"
|
||||
docker push "${IMAGE}:latest"
|
||||
}
|
||||
|
||||
require "$VERSION" "version"
|
||||
|
||||
set -xe
|
||||
|
||||
build_image asonix/mastodon arm64v8
|
3
mastodon/root/usr/bin/mastodon-media
Executable file
3
mastodon/root/usr/bin/mastodon-media
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
bundle exec bin/tootctl media remove
|
3
mastodon/root/usr/bin/mastodon-migrate
Executable file
3
mastodon/root/usr/bin/mastodon-migrate
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
bundle exec rails db:migrate
|
3
mastodon/root/usr/bin/mastodon-sidekiq
Executable file
3
mastodon/root/usr/bin/mastodon-sidekiq
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
bundle exec sidekiq -c ${MAX_THREADS:-4} -q default -q mailers -q pull -q push
|
3
mastodon/root/usr/bin/mastodon-statuses
Executable file
3
mastodon/root/usr/bin/mastodon-statuses
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
bundle exec bin/tootctl statuses remove
|
3
mastodon/root/usr/bin/mastodon-streaming
Executable file
3
mastodon/root/usr/bin/mastodon-streaming
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
npm run start
|
3
mastodon/root/usr/bin/mastodon-web
Executable file
3
mastodon/root/usr/bin/mastodon-web
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
bundle exec puma -C config/puma.rb
|
Loading…
Reference in a new issue