Skip to content

Commit

Permalink
Merge pull request #325 from tigrisdata/main
Browse files Browse the repository at this point in the history
Releasing Server
  • Loading branch information
himank authored Jun 30, 2022
2 parents 1c67101 + c23d695 commit 1e3bfe5
Show file tree
Hide file tree
Showing 26 changed files with 1,088 additions and 153 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/push-docker-local-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: publish local docker image

on:
pull_request:
push:
branches:
- main
- alpha
release:
types: [published]
workflow_call:
secrets:
GH_DOCKER_ACCESS_USER:
required: true
GH_DOCKER_ACCESS_TOKEN:
required: true

env:
DOCKER_REPOSITORY: "tigrisdata/tigris-local"

jobs:
build-and-push-local-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Fetch tags
run: |
git fetch --prune --unshallow --tags
- name: Login to Docker Hub
id: login-docker-hub
uses: docker/login-action@v1
with:
username: ${{ secrets.GH_DOCKER_ACCESS_USER }}
password: ${{ secrets.GH_DOCKER_ACCESS_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ env.DOCKER_REPOSITORY }}
# generate Docker tags based on the following events/attributes
# we generate the latest tag off the alpha branch
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/alpha' }}
- name: Pull submodules
run: git submodule update --init --recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile.local
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DATA_PROTO_DIR=internal

# Needed to be able to build amd64 binaries on MacOS M1
DOCKER_DIR=test/docker
DOCKER_COMPOSE=COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f ${DOCKER_DIR}/docker-compose.yml
DOCKER_COMPOSE=COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -f ${DOCKER_DIR}/docker-compose.yml
CGO_ENABLED=1

all: server
Expand Down Expand Up @@ -48,28 +48,28 @@ docker_compose_build:
# dependency on generate needed to create generated file outside of docker with
# current user owner instead of root
docker_test: generate
$(DOCKER_COMPOSE) up --build --abort-on-container-exit --exit-code-from tigris_test tigris_test
$(DOCKER_COMPOSE) up --build tigris_test tigris_test

docker_test_no_build:
$(DOCKER_COMPOSE) up --no-build --abort-on-container-exit --exit-code-from tigris_test tigris_test
$(DOCKER_COMPOSE) up --no-build tigris_test tigris_test

test: clean docker_test
test: docker_test

# Use this target to run the test from inside docker container
local_test: generate
go test $(TEST_PARAM) ./...

run: clean generate
run: generate
$(DOCKER_COMPOSE) up --build --detach tigris_server2

local_run: server
$(DOCKER_COMPOSE) up --no-build --detach tigris_search tigris_fdb
fdbcli -C ./test/config/fdb.cluster --exec "configure new single memory"
$(DOCKER_COMPOSE) up --no-build --detach tigris_search tigris_db
fdbcli -C ./test/config/fdb.cluster --exec "configure new single memory" || true
TIGRIS_ENVIRONMENT=dev ./server/service

# Runs tigris server and foundationdb, plus additional tools for it like:
# - prometheus and grafana for monitoring
run_full: clean generate
run_full: generate
${DOCKER_COMPOSE} up --build --detach tigris_grafana
./${DOCKER_DIR}/grafana/set_admin_password.sh
./${DOCKER_DIR}/grafana/add_prometheus_datasource.sh
Expand Down
2 changes: 1 addition & 1 deletion api/proto
Submodule proto updated from f910e0 to 2d7f25
2 changes: 1 addition & 1 deletion api/server/v1/marshaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestJSONEncoding(t *testing.T) {
Found: 1234,
Page: &Page{
Current: 2,
PerPage: 10,
Size: 10,
},
}}
r, err := json.Marshal(resp)
Expand Down
10 changes: 6 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:jammy-20220531 AS build
FROM ubuntu:20.04 AS build

RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
wget \
curl \
gcc \
git \
golang \
make \
sudo

RUN mkdir /build

COPY scripts/install_go.sh /build
RUN sh /build/install_go.sh
#Download deps once, during docker build. Rebuild only on go.mod change
ENV PATH="${PATH}:/root/go/bin"
ENV PATH="${PATH}:/root/go/bin:/usr/local/go/bin"
COPY scripts/install_build_deps.sh /build
RUN sh /build/install_build_deps.sh
COPY go.mod /build
Expand All @@ -38,7 +40,7 @@ COPY . /build
RUN --mount=type=cache,target=/root/.cache/go-build rm -f server/service && make bins


FROM ubuntu:jammy-20220531 AS server
FROM ubuntu:20.04 AS server

# Remove apt configuration
RUN rm -rf /etc/apt/*
Expand Down
85 changes: 85 additions & 0 deletions docker/Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Copyright 2022 Tigris Data, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ubuntu:20.04 AS build

RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
wget \
gcc \
git \
make \
sudo

RUN mkdir /build

COPY scripts/install_go.sh /build
RUN sh /build/install_go.sh
#Download deps once, during docker build. Rebuild only on go.mod change
ENV PATH="${PATH}:/root/go/bin:/usr/local/go/bin"
COPY scripts/install_build_deps.sh /build
RUN sh /build/install_build_deps.sh
COPY go.mod /build
WORKDIR /build
RUN go mod download
COPY . /build
RUN --mount=type=cache,target=/root/.cache/go-build rm -f server/service && make bins


FROM ubuntu:20.04 AS server

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
tree

COPY scripts/install_local_docker_deps.sh /tmp/
RUN /bin/bash /tmp/install_local_docker_deps.sh && rm /tmp/install_local_docker_deps.sh

# Remove apt configuration
RUN rm -rf /etc/apt/* /var/lib/dpkg/* /var/lib/apt/*

# Setup an unprivileged user
RUN groupadd -r tigris && useradd -r -s /bin/false -g tigris tigris

RUN mkdir -p /server /etc/tigrisdata/tigris /etc/foundationdb /var/lib/foundationdb/logs

COPY --from=build /build/server/service /server/service
COPY --from=build /build/config/server.yaml /etc/tigrisdata/tigris
COPY --from=build /usr/lib/libfdb_c.so /usr/lib/libfdb_c.so
COPY --from=build /usr/bin/fdbcli /usr/bin/fdbcli

RUN chown -R tigris:tigris /server /etc/tigrisdata/tigris

#RUN echo "docker:[email protected]:4500" >/etc/foundationdb/fdb.cluster
RUN echo "#!/bin/bash\n \
/usr/bin/typesense-server --config=/etc/typesense/typesense-server.ini & \n \
fdbserver --listen-address 127.0.0.1:4500 --public-address 127.0.0.1:4500 --datadir /var/lib/foundationdb/data --logdir /var/lib/foundationdb/logs --locality-zoneid tigris --locality-machineid tigris & \n\
export TIGRIS_SERVER_SEARCH_AUTH_KEY=ts_dev_key \n \
export TIGRIS_SERVER_SEARCH_HOST=localhost \n \
fdbcli --exec 'configure new single memory' \n \
/server/service\n" >/server/service.sh

EXPOSE 8081

WORKDIR /server

# Set the default effective user to an unprivileged user
#USER tigris

CMD ["/bin/bash", "/server/service.sh"]
52 changes: 0 additions & 52 deletions docker/local/docker-compose.yaml

This file was deleted.

15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,35 @@ require (
google.golang.org/genproto v0.0.0-20220615141314-f1464d18c36b
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
gopkg.in/DataDog/dd-trace-go.v1 v1.38.1
gopkg.in/gavv/httpexpect.v1 v1.1.3
gopkg.in/yaml.v2 v2.4.0
)

require (
cloud.google.com/go/compute v1.6.1 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.0.0-20211129110424-6491aa3bf583 // indirect
github.com/DataDog/datadog-go v4.8.2+incompatible // indirect
github.com/DataDog/datadog-go/v5 v5.0.2 // indirect
github.com/DataDog/gostackparse v0.5.0 // indirect
github.com/DataDog/sketches-go v1.0.0 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/deepmap/oapi-codegen v1.11.0 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gavv/monotime v0.0.0-20190418164738-30dba4353424 // indirect
github.com/gertd/go-pluralize v0.2.1 // indirect
github.com/getkin/kin-openapi v0.97.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
Expand All @@ -75,6 +87,7 @@ require (
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/philhofer/fwd v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sergi/go-diff v1.0.0 // indirect
Expand All @@ -84,6 +97,7 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/tinylib/msgp v1.1.2 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
github.com/valyala/fasthttp v1.34.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
Expand All @@ -99,6 +113,7 @@ require (
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc/examples v0.0.0-20220215234149-ec717cad7395 // indirect
Expand Down
Loading

0 comments on commit 1e3bfe5

Please sign in to comment.