diff --git a/.github/workflows/build-ferretdb.yml b/.github/workflows/build-ferretdb.yml new file mode 100644 index 0000000..89ac3fa --- /dev/null +++ b/.github/workflows/build-ferretdb.yml @@ -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 }} \ No newline at end of file diff --git a/ferretdb/Dockerfile b/ferretdb/Dockerfile new file mode 100644 index 0000000..de20d4c --- /dev/null +++ b/ferretdb/Dockerfile @@ -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 " \ No newline at end of file diff --git a/ferretdb/README.md b/ferretdb/README.md new file mode 100644 index 0000000..72e952b --- /dev/null +++ b/ferretdb/README.md @@ -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/). \ No newline at end of file