th: ci and image builds

Co-authored-by: Ariadne Conill <ariadne@dereferenced.org>
main
kouhai 2024-04-15 00:33:47 -07:00
parent eebab21aa2
commit 9a9450f205
4 changed files with 106 additions and 15 deletions

View File

@ -1,22 +1,41 @@
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# Order-independent
*.sw*
*.swp
*~
.DS_Store
.bundle
.env
.env.*
.git
.gitattributes
.gitignore
.github
public/system
.gitignore
.woodpecker.yml
/*.md
build
chart
coverage
data
elasticsearch
log
neo4j
node_modules
postgres
postgres*
postgres14
public/assets
public/packs
public/packs-test
node_modules
neo4j
vendor/bundle
.DS_Store
*.swp
*~
postgres
postgres14
public/system
redis
elasticsearch
chart
sorbet
tmp
vendor/bundle

58
.woodpecker.yml Normal file
View File

@ -0,0 +1,58 @@
variables:
environment: &docker-environment
SERVER_IMAGE: gitea.treehouse.systems/treehouse/mastodon
STREAMING_IMAGE: gitea.treehouse.systems/treehouse/mastodon-streaming
DATE_COMMAND: export COMMIT_DATE=$(date -u -Idate -d @$(git show -s --format=%ct))
docker-step: &docker-step
image: docker:rc-git
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
<<: *docker-environment
clone:
git:
image: woodpeckerci/plugin-git
settings:
partial: false
depth: 10
pipeline:
output:
<<: *docker-step
commands:
- eval $DATE_COMMAND
- export TAG=$${COMMIT_DATE}.$CI_COMMIT_SHA && echo $${TAG}
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $SERVER_IMAGE:$${TAG}
- docker image build -f streaming/Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $STREAMING_IMAGE:$${TAG}
- docker tag $SERVER_IMAGE:$${TAG} $SERVER_IMAGE:latest
- docker tag $STREAMING_IMAGE:$${TAG} $STREAMING_IMAGE:latest
- echo -n > tags.txt
- echo $${TAG} | tee -a tags.txt
- echo latest | tee -a tags.txt
# maybe we can use tags someday,,,
# tag-tag:
# image: *docker-git
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# commands:
# - docker tag $SERVER_IMAGE:latest $SERVER_IMAGE:$CI_COMMIT_TAG
# when:
# event: tag
push:
<<: *docker-step
commands:
- echo $REGISTRY_SECRET | docker login -u $REGISTRY_USER --password-stdin gitea.treehouse.systems
- cat tags.txt | xargs -n 1 -I% echo docker image push $SERVER_IMAGE:%
- cat tags.txt | xargs -n 1 -I% docker image push $SERVER_IMAGE:%
- cat tags.txt | xargs -n 1 -I% echo docker image push $STREAMING_IMAGE:%
- cat tags.txt | xargs -n 1 -I% docker image push $STREAMING_IMAGE:%
when:
event: [push, tag]
branch: main
secrets: [REGISTRY_SECRET]
environment:
<<: *docker-environment
REGISTRY_USER: ariadne

View File

@ -30,6 +30,8 @@ ARG MASTODON_VERSION_PRERELEASE=""
# Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="pr-123456"]
ARG MASTODON_VERSION_METADATA=""
ARG SOURCE_TAG=""
# Allow Ruby on Rails to serve static files
# See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files
ARG RAILS_SERVE_STATIC_FILES="true"
@ -121,13 +123,13 @@ RUN \
# Create temporary build layer from base image
FROM ruby AS build
COPY --from=node /usr/local/bin /usr/local/bin
COPY --from=node /usr/local/lib /usr/local/lib
# Copy Node package configuration files into working directory
COPY package.json yarn.lock .yarnrc.yml /opt/mastodon/
COPY .yarn /opt/mastodon/.yarn
COPY --from=node /usr/local/bin /usr/local/bin
COPY --from=node /usr/local/lib /usr/local/lib
ARG TARGETPLATFORM
# hadolint ignore=DL3008

12
bin/test.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -eux
export NODE_ENV=production
export RAILS_ENV=production
bundle exec rake assets:clobber
bundle exec rake assets:precompile
export RAILS_ENV=test
bundle exec rake spec