Skip to content

Commit a55ab13

Browse files
committed
refactor: building of docker images is more flexible
1 parent 3981912 commit a55ab13

File tree

6 files changed

+125
-23
lines changed

6 files changed

+125
-23
lines changed

.github/workflows/scip-docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
pull_request:
88
paths:
99
- '.github/workflows/**'
10-
- 'Dockerfile.autoindex'
10+
- 'Dockerfile'
1111

1212
jobs:
1313
build-image:
@@ -41,7 +41,7 @@ jobs:
4141
id: docker_build_autoindex
4242
uses: docker/build-push-action@v4
4343
with:
44-
file: Dockerfile.autoindex
44+
file: Dockerfile
4545
push: false
4646
tags: |
4747
sourcegraph/scip-python:test

.github/workflows/scip-release.yml

Lines changed: 77 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@ name: release-scip
22

33
on:
44
push:
5+
branches:
6+
scip
57
tags:
68
- v*
79

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
814
jobs:
9-
release-image:
15+
publish:
1016
runs-on: ubuntu-latest
1117
steps:
12-
- uses: actions/checkout@v3
13-
- uses: docker/setup-buildx-action@v2
14-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
1520
with:
1621
node-version: '16'
1722
registry-url: 'https://registry.npmjs.org'
@@ -20,18 +25,77 @@ jobs:
2025
- run: cd ./packages/pyright-scip/ && npm publish --access public
2126
env:
2227
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
23-
- name: Login to DockerHub
24-
uses: docker/login-action@v2
28+
29+
docker:
30+
needs: publish
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
version_debian: [bookworm]
35+
version_python: [3.10]
36+
version_node: [16]
37+
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: read
41+
packages: write
42+
attestations: write
43+
id-token: write
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: docker/login-action@v3
2548
with:
26-
username: ${{ secrets.DOCKER_USERNAME }}
27-
password: ${{ secrets.DOCKER_PASSWORD }}
28-
- name: Build and push
29-
id: docker_build_autoindex
30-
uses: docker/build-push-action@v4
49+
registry: ${{ vars.REGISTRY || null }}
50+
username: ${{ secrets.DOCKER_USERNAME || github.actor }}
51+
password: ${{ secrets.DOCKER_PASSWORD || secrets.GITHUB_TOKEN }}
52+
53+
# We build over more platforms and hence need QEMU and more control!
54+
- uses: docker/setup-qemu-action@v3
55+
- uses: docker/setup-buildx-action@v3
56+
57+
- name: Generate image tags
58+
id: meta
59+
uses: docker/metadata-action@v5
3160
with:
32-
file: Dockerfile.autoindex
33-
push: true
61+
# list of Docker images to use as base name for tags
62+
images: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }}
63+
flavor: |
64+
latest=true
3465
tags: |
66+
type=schedule
67+
type=ref,event=tag
68+
type=sha,
69+
type=raw,value=autoindex
70+
type=semver,pattern={{version}}
71+
type=semver,pattern={{major}}.{{minor}}
72+
type=semver,pattern={{major}}
73+
3574
sourcegraph/scip-python:autoindex
3675
sourcegraph/scip-python:latest
3776
sourcegraph/scip-python:${{ github.ref_name }}
77+
78+
- name: Build and release image
79+
id: push
80+
uses: docker/build-push-action@v5
81+
with:
82+
context: images
83+
file: images/php.Dockerfile
84+
cache-from: type=gha,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }}
85+
cache-to: type=gha,mode=max,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }}
86+
push: true
87+
tags: ${{ steps.meta.outputs.tags }}
88+
labels: ${{ steps.meta.outputs.labels }}
89+
platforms: linux/amd64,linux/arm64
90+
build-args: |-
91+
VERSION_DEBIAN=${{ matrix.version_debian }}
92+
VERSION_PYTHON=${{ matrix.version_python }}
93+
VERSION_NODE=${{ matrix.version_node }}
94+
VERSION_SCIP_PYTHON=${{ github.ref_name }}
95+
96+
- name: Generate artifact attestation
97+
uses: actions/attest-build-provenance@v1
98+
with:
99+
subject-name: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }}
100+
subject-digest: ${{ steps.push.outputs.digest }}
101+
push-to-registry: true

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"editor.formatOnSave": true
99
},
1010
"editor.codeActionsOnSave": {
11-
"source.fixAll.eslint": true
11+
"source.fixAll.eslint": "explicit"
1212
},
1313
"typescript.tsdk": "node_modules/typescript/lib"
1414
}

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
ARG VERSION_DEBIAN=bookworm
2+
3+
ARG VERSION_NODE=16
4+
ARG VERSION_PYTHON=3.10
5+
6+
ARG VERSION_SCIP_PYTHON=v0.6.0
7+
8+
FROM node:$VERSION_NODE-$VERSION_DEBIAN-slim as technology-node
9+
FROM python:$VERSION_PYTHON-slim-$VERSION_DEBIAN as technology-python
10+
11+
FROM buildpack-deps:$VERSION_DEBIAN as base
12+
13+
COPY --link --from=technology-node /usr/local /usr/local
14+
COPY --link --from=technology-python /usr/local /usr/local
15+
16+
# NOTE: ldconfig is needed for Python to understand where shared libraries are.
17+
RUN ldconfig \
18+
# We remove pre-installed yarn and enable corepack.
19+
&& rm -rf /usr/local/bin/yarn* \
20+
&& corepack enable \
21+
# NOTE: Smoke tests while having as little side effects as possible.
22+
&& node --version \
23+
&& yarn --version \
24+
&& npm --logs-max=0 --version \
25+
&& PYTHONDONTWRITEBYTECODE=1 python3 --version \
26+
&& pip --version
27+
28+
FROM base AS release
29+
30+
ARG VERSION_SCIP_PYTHON
31+
32+
# Install dependencies
33+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
34+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
35+
apt-get update && apt-get install -y --no-install-recommends \
36+
git \
37+
bash \
38+
curl \
39+
&& rm -rf /var/lib/apt/lists/*
40+
41+
# Install packages
42+
RUN npm install -g @sourcegraph/scip-python@$VERSION_SCIP_PYTHON @sourcegraph/src
43+
44+
ENTRYPOINT [ "scip-python" ]

Dockerfile.autoindex

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ # Install scip-python
1111
$ npm install -g @sourcegraph/scip-python
1212
```
1313

14-
scip-python requires Node v16 or newer. See the [Dockerfile](https://github.com/sourcegraph/scip-python/blob/scip/Dockerfile.autoindex) for an exact SHA that is tested.
14+
scip-python requires Node v16 or newer. See the [Dockerfile](https://github.com/sourcegraph/scip-python/blob/scip/Dockerfile) for an exact SHA that is tested.
1515

1616
scip-python uses `pip` to attempt to determine the versions and names of the packages available in your environment. If you do not use pip to install the packages, you can instead use the `--environment` flag to supply a list of packages to use as the environment. This will skip any calls out to pip to determine the state of your env. See [Environment](##-environment) for more information.
1717

0 commit comments

Comments
 (0)