Skip to content

Instantly share code, notes, and snippets.

@edmorley
Created December 3, 2019 17:19
Show Gist options
  • Save edmorley/85dd6a99f8d21c6f730551fb1d8b0d91 to your computer and use it in GitHub Desktop.
Save edmorley/85dd6a99f8d21c6f730551fb1d8b0d91 to your computer and use it in GitHub Desktop.
libpq v12 testcase: ruby-pg
testcase:
build: .
links:
- db
db:
image: postgres:11.5-alpine
FROM ruby:2.6.5-buster
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /etc/apt/trusted.gpg.d/pgdg.asc
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main' > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev \
&& rm -rf /var/lib/apt/lists/*
RUN gem install pg
COPY testcase.rb .
CMD ["ruby", "testcase.rb"]
require "pg"
connection_parameters = {
host: "db",
user: "postgres",
connect_timeout: "15s",
}
conn = PG.connect(connection_parameters)
conn.exec("SELECT 'test'") do |result|
puts "Succeeded"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment