Skip to content

Commit

Permalink
feat(ferretdb): add image
Browse files Browse the repository at this point in the history
  • Loading branch information
f-bn committed Apr 13, 2024
1 parent f3ce828 commit d79d01c
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build-ferretdb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Build FerretDB image
on:
push:
branches:
- main
paths:
- ferretdb/**
- .github/workflows/ferretdb.yml
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
version: ['1.21.0']
steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Set up QEMU (for multi-arch build)
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image to registry
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
context: ./ferretdb
file: ./ferretdb/Dockerfile
push: true
build-args: |
VERSION=${{ matrix.version }}
tags: |
ghcr.io/f-bn/ferretdb:${{ matrix.version }}
55 changes: 55 additions & 0 deletions ferretdb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# --- Build stage ---
FROM docker.io/golang:1.22.2 AS build

ARG TARGETOS
ARG TARGETARCH
ARG VERSION=1.21.0

ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
ENV GOAMD64=v1
ENV CGO_ENABLED=0

WORKDIR /build

RUN git clone --single-branch --branch v${VERSION} https://github.com/FerretDB/FerretDB.git /build
RUN set -ex ; \
# https://pkg.go.dev/github.com/FerretDB/FerretDB/build/version
echo "v${VERSION}" | tee ./build/version/version.txt ; \
echo "$(git rev-parse HEAD)" | tee ./build/version/commit.txt ; \
echo "docker" | tee ./build/version/package.txt ; \
go build -v -o=./bin/ferretdb ./cmd/ferretdb

# --- Final stage ---
FROM cgr.dev/chainguard/wolfi-base:latest

ARG VERSION

COPY --from=build --chmod=755 /build/bin/ferretdb /usr/bin/ferretdb

RUN set -ex ; \
mkdir -p /var/lib/ferretdb ; \
chown nonroot:nonroot /var/lib/ferretdb

ENV FERRETDB_LISTEN_ADDR=:27017
ENV FERRETDB_DEBUG_ADDR=:8088
ENV FERRETDB_STATE_DIR=/var/lib/ferretdb
ENV FERRETDB_HANDLER=pg
ENV FERRETDB_SQLITE_URL="file:${FERRETDB_STATE_DIR}/"
ENV FERRETDB_LOG_LEVEL=info
ENV FERRETDB_TELEMETRY=off

USER nonroot

EXPOSE 27017/tcp 27018/tcp 8088/tcp

VOLUME [ "/var/lib/ferretdb" ]

ENTRYPOINT [ "/usr/bin/ferretdb" ]

LABEL \
org.opencontainers.image.title="FerretDB" \
org.opencontainers.image.source="https://github.com/f-bn/containers-images/ferretdb" \
org.opencontainers.image.description="A truly Open Source MongoDB alternative" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.authors="Florian Bobin <[email protected]>"
13 changes: 13 additions & 0 deletions ferretdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## General informations

Custom FerretDB image builded from sources.

Built with Go 1.22.2.

### Supported FerretDB versions

- FerretDB 1.21.x

## FerretDB configuration

FerretDB is able to read configuration from environment variables or flags, this is still valid for this custom image. More informations [here](https://docs.ferretdb.io/configuration/flags/).

0 comments on commit d79d01c

Please sign in to comment.