th: fun, image tagging, and SOURCE_TAG

pull/59/head
kouhai dev 2023-03-16 21:09:27 -07:00
parent 0382d1efe7
commit c9a49fc3dd
3 changed files with 45 additions and 20 deletions

View File

@ -1,19 +1,38 @@
variables:
docker-step: &docker-step
image: docker:rc-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
NAME: gitea.treehouse.systems/treehouse/mastodon
pipeline:
build:
image: docker:rc-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
<<: *docker-step
commands:
- docker version
- docker image build -f Dockerfile . -t gitea.treehouse.systems/treehouse/mastodon:latest
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME:latest
- docker tag $NAME:latest $NAME:$CI_COMMIT_SHA
tag-nightly:
<<: *docker-step
commands:
- docker tag $NAME:latest $NAME:$(date -Idate -u)
# maybe we can use tags someday,,,
# tag-tag:
# image: *docker-git
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# commands:
# - docker tag $NAME:latest $NAME:$CI_COMMIT_TAG
# when:
# event: tag
push:
image: docker:rc-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
<<: *docker-step
commands:
- echo $REGISTRY_SECRET | docker login -u ariadne --password-stdin gitea.treehouse.systems
- docker image push --all-tags gitea.treehouse.systems/treehouse/mastodon
- docker image push --all-tags $NAME
when:
event: [push, tag]
branch: main

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
# This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
ARG NODE_VERSION="16.19-bullseye-slim"
ARG NODE_VERSION="18.15-bullseye-slim"
FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.1-slim as ruby
FROM node:${NODE_VERSION} as build
@ -8,7 +8,8 @@ FROM node:${NODE_VERSION} as build
COPY --link --from=ruby /opt/ruby /opt/ruby
ENV DEBIAN_FRONTEND="noninteractive" \
PATH="${PATH}:/opt/ruby/bin"
PATH="${PATH}:/opt/ruby/bin" \
NODE_OPTIONS=--openssl-legacy-provider
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@ -50,15 +51,17 @@ ENV RAILS_ENV="production" \
# Precompile assets
# TODO(kouhai): we're currently patching node_modules because of emoji-mart.
# we should integrate our own fork instead.
COPY ./emoji_data/all.json ./node_modules/emoji-mart/data/all.json
COPY --link . /opt/mastodon
ENV OTP_SECRET=precompile_placeholder \
SECRET_KEY_BASE=precompile_placeholder \
RAKE_NO_YARN_INSTALL_HACK=1
RUN bundle exec rails assets:precompile
RUN mv ./emoji_data/all.json ./node_modules/emoji-mart/data/all.json && \
bundle exec rails assets:precompile
FROM node:${NODE_VERSION}
ARG SOURCE_TAG=''
ARG UID="991"
ARG GID="991"
@ -96,13 +99,13 @@ RUN apt-get update && \
# Note: no, cleaning here since Debian does this automatically
# See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem
COPY --link --chown=mastodon:mastodon . /opt/mastodon
COPY --link --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
ENV RAILS_ENV="production" \
NODE_ENV="production" \
RAILS_SERVE_STATIC_FILES="true" \
BIND="0.0.0.0"
BIND="0.0.0.0" \
SOURCE_TAG="${SOURCE_TAG}"
# Set the run user
USER mastodon

View File

@ -21,7 +21,7 @@ module Mastodon
end
def suffix
'+glitch+th'
'+glitch.th'
end
def to_a
@ -42,15 +42,18 @@ module Mastodon
# specify git tag or commit hash here
def source_tag
ENV.fetch('SOURCE_TAG', nil)
tag = ENV.fetch('SOURCE_TAG', nil)
return if tag.nil? || tag.empty?
tag
end
def source_url
if source_tag && source_base_url =~ /gitea/
suffix = if !str[/\H/]
"commit/#{source_tag}"
tag = source_tag
if tag && source_base_url =~ /gitea/
suffix = if !tag[/\H/]
"commit/#{tag}"
else
"branch/#{source_tag}"
"branch/#{tag}"
end
"#{source_base_url}/#{suffix}"
else