Skip to content

Commit 082f08d

Browse files
authored
Merge pull request #251 from launchql/anmol/launchql-docker
docker: add launchql dockerfile
2 parents 896c65d + b983fa5 commit 082f08d

4 files changed

Lines changed: 138 additions & 6 deletions

File tree

.github/workflows/docker.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ on:
2020
workflow_dispatch:
2121
inputs:
2222
process:
23-
description: 'Process to build (pgvector | node-sqitch | postgis)'
23+
description: 'Process to build (pgvector | node-sqitch | postgis | pgvector-postgis | launchql)'
2424
type: choice
2525
required: true
2626
options:
2727
- pgvector
2828
- node-sqitch
2929
- postgis
3030
- pgvector-postgis
31+
- launchql
3132
default: pgvector
3233
version:
3334
description: 'Specific version to build (must exist in version.yaml)'
@@ -95,3 +96,55 @@ jobs:
9596
REPO_NAME=$REPO \
9697
PLATFORMS="$PLATFORMS" \
9798
build-push-process
99+
100+
build-launchql:
101+
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
102+
runs-on: ubuntu-latest
103+
104+
permissions:
105+
contents: read
106+
packages: write
107+
108+
defaults:
109+
run:
110+
working-directory: docker
111+
112+
env:
113+
REPO: ghcr.io/${{ github.repository_owner }}
114+
PLATFORMS: linux/amd64,linux/arm64
115+
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
120+
- name: Set up QEMU
121+
uses: docker/setup-qemu-action@v3
122+
123+
- name: Set up Docker Buildx
124+
uses: docker/setup-buildx-action@v3
125+
126+
- name: Login to GHCR
127+
if: github.event_name != 'pull_request'
128+
uses: docker/login-action@v3
129+
with:
130+
registry: ghcr.io
131+
username: ${{ github.actor }}
132+
password: ${{ secrets.GITHUB_TOKEN }}
133+
134+
- name: Build LaunchQL (no push)
135+
if: github.event_name == 'pull_request'
136+
run: |
137+
make \
138+
PROCESS=launchql \
139+
REPO_NAME=$REPO \
140+
PLATFORMS="$PLATFORMS" \
141+
build-process
142+
143+
- name: Build and push LaunchQL (all versions)
144+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
145+
run: |
146+
make \
147+
PROCESS=launchql \
148+
REPO_NAME=$REPO \
149+
PLATFORMS="$PLATFORMS" \
150+
build-push-process

docker/Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PLATFORMS?=linux/arm64
88
PROCESS?=pgvector
99

1010
# Convenience: list of known processes
11-
PROCESSES:=pgvector node-sqitch postgis pgvector-postgis
11+
PROCESSES:=pgvector node-sqitch postgis pgvector-postgis launchql
1212

1313
CONTAINER_NAME?=$(PROCESS)
1414

@@ -54,26 +54,42 @@ build-process-version:
5454
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
5555
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
5656
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (build)"
57-
@docker buildx build \
57+
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
58+
CONTEXT=$$( \
59+
if [ "$(PROCESS)" = "launchql" ]; then \
60+
echo ".."; \
61+
else \
62+
echo "$(PROCESS)"; \
63+
fi ); \
64+
docker buildx build \
5865
--platform $(PLATFORMS) \
5966
--build-arg BASE=$(BASE) \
6067
--build-arg BASE_VERSION=$(VERSION) \
68+
--file $$DOCKERFILE_PATH \
6169
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
62-
$(PROCESS)
70+
$$CONTEXT
6371

6472
# Build+push only a specific VERSION for $(PROCESS). Intended for internal use by build-push-process.
6573
# Usage (internal): $(MAKE) BASE=<base> VERSION=<version> build-push-process-version
6674
build-push-process-version:
6775
@test -n "$(BASE)" || { echo "Error: BASE is required"; exit 1; }
6876
@test -n "$(VERSION)" || { echo "Error: VERSION is required"; exit 1; }
6977
@echo " -> $(BASE):$(VERSION) => $(REPO_NAME)/$(PROCESS):$(VERSION) (push)"
70-
@docker buildx build \
78+
@DOCKERFILE_PATH="$(PROCESS)/Dockerfile"; \
79+
CONTEXT=$$( \
80+
if [ "$(PROCESS)" = "launchql" ]; then \
81+
echo ".."; \
82+
else \
83+
echo "$(PROCESS)"; \
84+
fi ); \
85+
docker buildx build \
7186
--platform $(PLATFORMS) \
7287
--build-arg BASE=$(BASE) \
7388
--build-arg BASE_VERSION=$(VERSION) \
89+
--file $$DOCKERFILE_PATH \
7490
-t $(REPO_NAME)/$(PROCESS):$(VERSION) \
7591
--push \
76-
$(PROCESS)
92+
$$CONTEXT
7793

7894
# Aliases
7995
all: build-all
@@ -91,3 +107,6 @@ postgis:
91107

92108
pgvector-postgis:
93109
$(MAKE) PROCESS=pgvector-postgis build-process
110+
111+
launchql:
112+
$(MAKE) PROCESS=launchql build-process

docker/launchql/Dockerfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
ARG BASE=node
2+
ARG BASE_VERSION=20-bookworm
3+
FROM ${BASE}:${BASE_VERSION} AS build
4+
5+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
6+
ARG BASE
7+
ARG BASE_VERSION
8+
ENV BASE_VERSION=${BASE_VERSION}
9+
10+
WORKDIR /app
11+
12+
# System deps for building native modules and tools used by the monorepo
13+
RUN set -eux; \
14+
apt-get update; \
15+
apt-get install -y --no-install-recommends \
16+
ca-certificates curl git python3 make g++; \
17+
update-ca-certificates || true; \
18+
corepack enable; \
19+
corepack prepare yarn@1.22.22 --activate; \
20+
rm -rf /var/lib/apt/lists/*
21+
22+
# Copy full repo (build context must be repo root when building this image)
23+
COPY . .
24+
25+
# Install and build all workspaces
26+
RUN set -eux; \
27+
yarn install --frozen-lockfile; \
28+
yarn build
29+
30+
################################################################################
31+
FROM ${BASE}:${BASE_VERSION} AS launchql
32+
33+
LABEL org.opencontainers.image.source="https://github.com/launchql/launchql"
34+
WORKDIR /app
35+
36+
# Runtime deps (psql optional but handy for debugging)
37+
RUN set -eux; \
38+
apt-get update; \
39+
apt-get install -y --no-install-recommends ca-certificates postgresql-client; \
40+
update-ca-certificates || true; \
41+
corepack enable; \
42+
corepack prepare yarn@1.22.22 --activate; \
43+
rm -rf /var/lib/apt/lists/*
44+
45+
# Copy built repo from builder
46+
COPY --from=build /app /app
47+
48+
# Lightweight shims to expose CLI on PATH
49+
RUN set -eux; \
50+
install -d /usr/local/bin; \
51+
printf '#!/usr/bin/env bash\nnode /app/packages/cli/dist/index.js "$@"\n' > /usr/local/bin/lql; \
52+
printf '#!/usr/bin/env bash\nnode /app/packages/cli/dist/index.js "$@"\n' > /usr/local/bin/launchql; \
53+
chmod +x /usr/local/bin/lql /usr/local/bin/launchql
54+
55+
ENTRYPOINT ["/usr/local/bin/lql"]
56+
CMD ["--help"]

docker/launchql/version.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
base: node
2+
versions:
3+
- 20-bookworm
4+

0 commit comments

Comments
 (0)