Skip to content

Commit f9dbb46

Browse files
committed
Add build scripts
1 parent c73652c commit f9dbb46

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

docker/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM europe-west4-docker.pkg.dev/core-infra-onesignal/development/rust-ubuntu:1.78.0-r1 AS builder
2+
COPY . /app
3+
WORKDIR /app
4+
RUN cargo build --release
5+
6+
FROM europe-west4-docker.pkg.dev/core-infra-onesignal/development/rust-runtime:bookworm-20231030-slim AS release
7+
WORKDIR /etc/pgcat
8+
ENV RUST_LOG=info
9+
RUN apt-get update && apt-get install -o Dpkg::Options::=--force-confdef -yq --no-install-recommends \
10+
postgresql-client \
11+
# Clean up layer
12+
&& apt-get clean \
13+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
14+
&& truncate -s 0 /var/log/*log
15+
COPY --from=builder /app/target/release/pgcat /usr/bin/pgcat
16+
COPY --from=builder /app/pgcat.toml /etc/pgcat/pgcat.toml
17+
EXPOSE 6432 9930
18+
ENTRYPOINT ["pgcat", "/etc/pgcat/pgcat.toml"]

script/build

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Purpose:
4+
#
5+
# Builds the docker images.
6+
7+
set -e
8+
[ -z "${DEBUG}" ] || set -x
9+
10+
SHA=$(git rev-parse HEAD || '')
11+
IMAGE=europe-west4-docker.pkg.dev/core-infra-onesignal/onesignal/pgcat
12+
13+
cd "$(dirname "$0")/.."
14+
15+
# parse the option parameters
16+
for i in "$@"; do
17+
case $i in
18+
no-cache)
19+
NO_CACHE="--no-cache"
20+
shift
21+
;;
22+
esac
23+
done
24+
25+
docker build --target release $NO_CACHE . -t $IMAGE:$SHA -f docker/Dockerfile

0 commit comments

Comments
 (0)