-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in AW/integresql from mr/aj-review to aj/pooling-improvements * commit '7b99232ec350445edf06f1b85dc650f32b32616d': don't lock while extending, reuse recreateDatabaseGracefully intro zerolog and add proper log statements in pool and manager, into typical go-starter logging middleware and additional env vars for controlling them private disableWorkerAutostart fix toolchain, reenable pipefails, fix linting, cleanup adds test database generations and TestDatabaseMinimalLifetime (blocks auto clean for specific time on issued databases) to properly deal with pressure caused by fast test db issuance and out-of-order recreates which might cause interferances adds backoff handling for recreateDatabaseGracefully redesign recreate handling filter via tmp channel without closing the initial, fix tests / stabilize via disabling worker autostart close, range and refill dirty channel on unlock and recreate, debug statements, use 1000 instead of 10e3 review only, reactivate print debugging
- Loading branch information
Showing
35 changed files
with
1,622 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
linters: | ||
enable: | ||
# https://github.com/golangci/golangci-lint#enabled-by-default-linters | ||
# Additional linters you want to activate may be specified here... | ||
|
||
# --- | ||
# https://github.com/mgechev/revive | ||
# replacement for the now deprecated official golint linter, see https://github.com/golang/go/issues/38968 | ||
- revive | ||
|
||
# --- | ||
# https://github.com/maratori/testpackage | ||
# used to enforce blackbox testing | ||
- testpackage | ||
|
||
# --- | ||
# https://github.com/securego/gosec | ||
# inspects source code for security problems by scanning the Go AST. | ||
- gosec | ||
|
||
# --- | ||
# https://github.com/sivchari/tenv | ||
# prefer t.Setenv instead of os.Setenv within test code. | ||
- tenv | ||
|
||
# --- | ||
# https://github.com/polyfloyd/go-errorlint | ||
# ensure we are comparing errors via errors.Is, types/values via errors.As and wrap errors with %w. | ||
- errorlint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,23 +18,55 @@ ENV MAKEFLAGS "-j 8 --no-print-directory" | |
# e.g. stretch=>stretch-pgdg, buster=>buster-pgdg, bullseye=>bullseye-pgdg | ||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" \ | ||
| tee /etc/apt/sources.list.d/pgdg.list \ | ||
&& apt install curl ca-certificates gnupg \ | ||
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null | ||
|
||
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \ | ||
| apt-key add - | ||
|
||
# Install required system dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
# | ||
# Mandadory minimal linux packages | ||
# Installed at development stage and app stage | ||
# Do not forget to add mandadory linux packages to the final app Dockerfile stage below! | ||
# | ||
# -- START MANDADORY -- | ||
ca-certificates \ | ||
# --- END MANDADORY --- | ||
# | ||
# Development specific packages | ||
# Only installed at development stage and NOT available in the final Docker stage | ||
# based upon | ||
# https://github.com/microsoft/vscode-remote-try-go/blob/master/.devcontainer/Dockerfile | ||
# https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-debian.sh | ||
# | ||
# icu-devtools: https://stackoverflow.com/questions/58736399/how-to-get-vscode-liveshare-extension-working-when-running-inside-vscode-remote | ||
# graphviz: https://github.com/google/pprof#building-pprof | ||
# -- START DEVELOPMENT -- | ||
apt-utils \ | ||
dialog \ | ||
openssh-client \ | ||
less \ | ||
iproute2 \ | ||
procps \ | ||
lsb-release \ | ||
locales \ | ||
sudo \ | ||
bash-completion \ | ||
bsdmainutils \ | ||
graphviz \ | ||
xz-utils \ | ||
postgresql-client-12 \ | ||
icu-devtools \ | ||
tmux \ | ||
rsync \ | ||
# --- END DEVELOPMENT --- | ||
# | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# vscode support: LANG must be supported, requires installing the locale package first | ||
# see https://github.com/Microsoft/vscode/issues/58015 | ||
# env/vscode support: LANG must be supported, requires installing the locale package first | ||
# https://github.com/Microsoft/vscode/issues/58015 | ||
# https://stackoverflow.com/questions/28405902/how-to-set-the-locale-inside-a-debian-ubuntu-docker-container | ||
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ | ||
dpkg-reconfigure --frontend=noninteractive locales && \ | ||
update-locale LANG=en_US.UTF-8 | ||
|
@@ -82,6 +114,25 @@ RUN ARCH="$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)" \ | |
# https://github.com/uw-labs/lichen/tags | ||
RUN go install github.com/uw-labs/[email protected] | ||
|
||
# watchexec | ||
# https://github.com/watchexec/watchexec/releases | ||
RUN mkdir -p /tmp/watchexec \ | ||
&& cd /tmp/watchexec \ | ||
&& wget https://github.com/watchexec/watchexec/releases/download/v1.20.6/watchexec-1.20.6-$(arch)-unknown-linux-musl.tar.xz \ | ||
&& tar xf watchexec-1.20.6-$(arch)-unknown-linux-musl.tar.xz \ | ||
&& cp watchexec-1.20.6-$(arch)-unknown-linux-musl/watchexec /usr/local/bin/watchexec \ | ||
&& rm -rf /tmp/watchexec | ||
|
||
# yq | ||
# https://github.com/mikefarah/yq/releases | ||
RUN mkdir -p /tmp/yq \ | ||
&& cd /tmp/yq \ | ||
&& ARCH="$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)" \ | ||
&& wget "https://github.com/mikefarah/yq/releases/download/v4.30.5/yq_linux_${ARCH}.tar.gz" \ | ||
&& tar xzf "yq_linux_${ARCH}.tar.gz" \ | ||
&& cp "yq_linux_${ARCH}" /usr/local/bin/yq \ | ||
&& rm -rf /tmp/yq | ||
|
||
# linux permissions / vscode support: Add user to avoid linux file permission issues | ||
# Detail: Inside the container, any mounted files/folders will have the exact same permissions | ||
# as outside the container - including the owner user ID (UID) and group ID (GID). | ||
|
@@ -100,7 +151,6 @@ RUN groupadd --gid $USER_GID $USERNAME \ | |
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
|
||
# vscode support: cached extensions install directory | ||
# https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild | ||
RUN mkdir -p /home/$USERNAME/.vscode-server/extensions \ | ||
|
@@ -113,7 +163,6 @@ RUN mkdir -p /home/$USERNAME/.vscode-server/extensions \ | |
# Note that this should be the final step after installing all build deps | ||
RUN mkdir -p /$GOPATH/pkg && chown -R $USERNAME /$GOPATH | ||
|
||
|
||
# $GOBIN is where our own compiled binaries will live and other go.mod / VSCode binaries will be installed. | ||
# It should always come AFTER our other $PATH segments and should be earliest targeted in stage "builder", | ||
# as /app/bin will the shadowed by a volume mount via docker-compose! | ||
|
@@ -133,15 +182,11 @@ COPY Makefile /app/Makefile | |
COPY go.mod /app/go.mod | ||
COPY go.sum /app/go.sum | ||
COPY tools.go /app/tools.go | ||
RUN make modules && make tools | ||
RUN make modules | ||
COPY tools.go /app/tools.go | ||
RUN make tools | ||
COPY . /app/ | ||
|
||
### ----------------------- | ||
# --- Stage: builder-integresql | ||
### ----------------------- | ||
|
||
FROM builder as builder-integresql | ||
RUN make build | ||
RUN make go-build | ||
|
||
### ----------------------- | ||
# --- Stage: integresql | ||
|
@@ -152,7 +197,7 @@ RUN make build | |
# The :debug image provides a busybox shell to enter. | ||
# https://github.com/GoogleContainerTools/distroless#debug-images | ||
FROM gcr.io/distroless/base-debian11:debug as integresql | ||
COPY --from=builder-integresql /app/bin/integresql / | ||
COPY --from=builder /app/bin/integresql / | ||
# Note that cmd is not supported with these kind of images, no shell included | ||
# see https://github.com/GoogleContainerTools/distroless/issues/62 | ||
# and https://github.com/GoogleContainerTools/distroless#entrypoints | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.