Skip to content

Commit 0ca6a9a

Browse files
committed
Initial commit
0 parents  commit 0ca6a9a

14 files changed

Lines changed: 601 additions & 0 deletions

File tree

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Ignore files that are not needed for building the base image
2+
.git
3+
.gitignore
4+
README.md
5+
*.md
6+
LICENSE
7+
examples/
8+
.github/
9+
Dockerfile*
10+
.dockerignore
11+
12+
# Common unnecessary files
13+
**/.DS_Store
14+
**/*~
15+
**/*.log
16+
tmp/
17+
log/
18+
vendor/bundle/ # if present in context
19+
node_modules/

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main, master]
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
# Build slim base (no push on PRs — only verification)
21+
- name: Build slim base
22+
uses: docker/build-push-action@v6
23+
with:
24+
context: .
25+
file: Dockerfile
26+
platforms: linux/amd64
27+
push: false
28+
tags: canis-base:pr
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max
31+
32+
# Build tools variant on top of the just-built base (no push on PRs)
33+
- name: Build tools variant
34+
uses: docker/build-push-action@v6
35+
with:
36+
context: .
37+
file: Dockerfile.tools
38+
platforms: linux/amd64
39+
push: false
40+
build-args: |
41+
BASE_IMAGE=canis-base:pr
42+
cache-from: type=gha
43+
cache-to: type=gha,mode=max

.github/workflows/release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Semantic version'
10+
required: true
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to DockerHub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
32+
- name: Login to GHCR
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Determine version
40+
id: version
41+
run: |
42+
if [ "${{ github.event_name }}" = "release" ]; then
43+
VERSION="${{ github.ref_name }}"
44+
else
45+
VERSION="${{ github.event.inputs.version }}"
46+
fi
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
48+
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
49+
50+
- name: Cache Docker layers
51+
uses: actions/cache@v4
52+
with:
53+
path: /tmp/.buildx-cache
54+
key: ${{ runner.os }}-buildx-${{ github.sha }}
55+
restore-keys: |
56+
${{ runner.os }}-buildx-
57+
58+
# Build and push slim base with semantic + hash tags to both registries
59+
- name: Build and push slim base
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
file: Dockerfile
64+
platforms: linux/amd64
65+
push: true
66+
tags: |
67+
datacite/canis-base:latest
68+
datacite/canis-base:${{ steps.version.outputs.version }}
69+
datacite/canis-base:${{ steps.version.outputs.sha }}
70+
ghcr.io/datacite/canis-base:latest
71+
ghcr.io/datacite/canis-base:${{ steps.version.outputs.version }}
72+
ghcr.io/datacite/canis-base:${{ steps.version.outputs.sha }}
73+
cache-from: type=local,src=/tmp/.buildx-cache
74+
cache-to: type=local,dest=/tmp/.buildx-cache
75+
76+
# Build and push tools variant on top of the exact base SHA to both registries
77+
- name: Build and push tools variant
78+
uses: docker/build-push-action@v6
79+
with:
80+
context: .
81+
file: Dockerfile.tools
82+
platforms: linux/amd64
83+
push: true
84+
tags: |
85+
datacite/canis-base-tools:latest
86+
datacite/canis-base-tools:${{ steps.version.outputs.version }}
87+
datacite/canis-base-tools:${{ steps.version.outputs.sha }}
88+
ghcr.io/datacite/canis-base-tools:latest
89+
ghcr.io/datacite/canis-base-tools:${{ steps.version.outputs.version }}
90+
ghcr.io/datacite/canis-base-tools:${{ steps.version.outputs.sha }}
91+
build-args: |
92+
BASE_IMAGE=ghcr.io/datacite/canis-base:${{ steps.version.outputs.sha }}
93+
cache-from: type=local,src=/tmp/.buildx-cache
94+
cache-to: type=local,dest=/tmp/.buildx-cache

Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# syntax=docker/dockerfile:1.7
2+
#
3+
# DataCite Canis Base Image (slim core)
4+
#
5+
# This is the minimal shared base used by all services.
6+
# Heavy operational tools live in Dockerfile.tools.
7+
8+
FROM phusion/passenger-ruby40:3.1.6
9+
10+
LABEL maintainer="support@datacite.org" \
11+
org.opencontainers.image.source="https://github.com/datacite/docker-canis-base" \
12+
org.opencontainers.image.description="DataCite Canis Base (slim core)"
13+
14+
ENV HOME=/home/app \
15+
LC_ALL=en_US.UTF-8 \
16+
LANG=en_US.UTF-8 \
17+
NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx/sites-enabled \
18+
DEBIAN_FRONTEND=noninteractive
19+
20+
# ============================================================================
21+
# Core system packages + native gem build dependencies
22+
# ============================================================================
23+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
24+
25+
RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold" && \
26+
apt-get install -y --no-install-recommends \
27+
# Common operational / debugging tools
28+
ntp wget ca-certificates gnupg tzdata shared-mime-info \
29+
nano tmux gettext unzip libxml2-utils imagemagick git curl jq \
30+
lsb-release \
31+
# Critical for Rails native extensions (mysql2, nokogiri, etc.)
32+
build-essential default-libmysqlclient-dev libxslt1-dev \
33+
libyaml-dev zlib1g-dev pkg-config \
34+
# Graphics / image processing libs (for rmagick, vips, etc.)
35+
libpng-dev libjpeg-dev libcairo2-dev libfreetype6-dev fontconfig \
36+
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
37+
38+
# ============================================================================
39+
# User permissions + git safety
40+
# ============================================================================
41+
RUN usermod -a -G docker_env app && \
42+
git config --global --add safe.directory /home/app/webapp
43+
44+
# ============================================================================
45+
# Ruby 4 + modern Bundler baseline
46+
# ============================================================================
47+
RUN bash -lc 'rvm --default use ruby-4.0.1 && gem install rubygems-update -v 3.5.6 && gem install bundler -v 2.6.9'
48+
49+
# ============================================================================
50+
# Standard Phusion layout
51+
# ============================================================================
52+
RUN rm -f /etc/service/nginx/down && \
53+
rm -f /etc/nginx/sites-enabled/default && \
54+
mkdir -p /etc/nginx/templates /etc/service/shoryuken /etc/my_init.d /etc/nginx/conf.d
55+
56+
# Copy common configuration and scripts from the base repo's vendor/docker/.
57+
# These match the layout used in other DataCite repos (lupo, levriero, etc.).
58+
# Apps can still override any of these by COPY-ing their own version later in their Dockerfile.
59+
COPY vendor/docker/ntp.conf /etc/ntp.conf
60+
COPY vendor/docker/00_app_env.conf /etc/nginx/conf.d/00_app_env.conf
61+
COPY vendor/docker/10_ssh.sh /etc/my_init.d/10_ssh.sh
62+
COPY vendor/docker/90_migrate.sh /etc/my_init.d/90_migrate.sh
63+
COPY vendor/docker/shoryuken.sh /etc/service/shoryuken/run
64+
65+
# Make sure init scripts are executable
66+
RUN chmod +x /etc/my_init.d/10_ssh.sh \
67+
/etc/my_init.d/90_migrate.sh \
68+
/etc/service/shoryuken/run
69+
70+
WORKDIR /home/app/webapp
71+
CMD ["/sbin/my_init"]
72+
EXPOSE 80

Dockerfile.tools

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# syntax=docker/dockerfile:1.7
2+
#
3+
# DataCite Canis Tools Image
4+
#
5+
# Builds on top of the slim canis-base and adds heavy operational tooling.
6+
# This image is intended primarily for Lupo and any services that might/will need
7+
# Percona Toolkit and AWS CLI at runtime.
8+
9+
ARG BASE_IMAGE=ghcr.io/datacite/canis-base:latest
10+
FROM ${BASE_IMAGE}
11+
12+
LABEL maintainer="support@datacite.org" \
13+
org.opencontainers.image.source="https://github.com/datacite/docker-canis-base" \
14+
org.opencontainers.image.description="DataCite Canis Base + Tools (Percona + AWS CLI + Dockerize + ...)"
15+
16+
ENV DOCKERIZE_VERSION=v0.6.0
17+
18+
# ============================================================================
19+
# Percona Toolkit 3.7.1 + Perl DBI libraries
20+
# ============================================================================
21+
RUN apt-get update && \
22+
apt-get install -y --no-install-recommends \
23+
libdbd-mysql-perl libdbi-perl libterm-readkey-perl libio-socket-ssl-perl && \
24+
wget -q https://downloads.percona.com/downloads/percona-toolkit/3.7.1/binary/debian/noble/x86_64/percona-toolkit_3.7.1-3.noble_amd64.deb -O /tmp/percona-toolkit.deb && \
25+
dpkg -i /tmp/percona-toolkit.deb || apt-get install -y -f --no-install-recommends && \
26+
rm -f /tmp/percona-toolkit.deb && \
27+
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
28+
29+
# ============================================================================
30+
# AWS CLI v2
31+
# ============================================================================
32+
RUN wget -q https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -O /tmp/awscliv2.zip && \
33+
unzip -q /tmp/awscliv2.zip -d /tmp && \
34+
/tmp/aws/install && \
35+
rm -rf /tmp/awscliv2.zip /tmp/aws && \
36+
apt-get clean
37+
38+
# ============================================================================
39+
# dockerize (wait-for pattern used by some services)
40+
# ============================================================================
41+
RUN wget -q https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-linux-amd64-${DOCKERIZE_VERSION}.tar.gz -O /tmp/dockerize.tar.gz && \
42+
tar -C /usr/local/bin -xzf /tmp/dockerize.tar.gz && \
43+
rm -f /tmp/dockerize.tar.gz
44+
45+
WORKDIR /home/app/webapp

0 commit comments

Comments
 (0)