Skip to content

Commit 31314b9

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

File tree

6 files changed

+128
-25
lines changed

6 files changed

+128
-25
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: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,101 @@ 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'
1823
- run: npm install
1924
- run: cd ./packages/pyright-scip/ && npm install && npm run build
20-
- run: cd ./packages/pyright-scip/ && npm publish --access public
25+
- if: ${{ env.NODE_AUTH_TOKEN }}
26+
run: cd ./packages/pyright-scip/ && npm publish --access public
2127
env:
22-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
23-
- name: Login to DockerHub
24-
uses: docker/login-action@v2
28+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29+
30+
docker:
31+
needs: publish
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
version_debian: [bookworm]
36+
version_python: [3.10]
37+
version_node: [16]
38+
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: read
42+
packages: write
43+
attestations: write
44+
id-token: write
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: docker/login-action@v3
2549
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
50+
registry: ${{ vars.REGISTRY || null }}
51+
username: ${{ secrets.DOCKER_USERNAME || github.actor }}
52+
password: ${{ secrets.DOCKER_PASSWORD || secrets.GITHUB_TOKEN }}
53+
54+
# We build over more platforms and hence need QEMU and more control!
55+
- uses: docker/setup-qemu-action@v3
56+
- uses: docker/setup-buildx-action@v3
57+
58+
- name: Generate image tags
59+
id: meta
60+
uses: docker/metadata-action@v5
3161
with:
32-
file: Dockerfile.autoindex
33-
push: true
62+
# list of Docker images to use as base name for tags
63+
images: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }}
64+
flavor: |
65+
latest=true
3466
tags: |
67+
type=schedule
68+
type=ref,event=tag
69+
type=sha,
70+
type=raw,value=autoindex
71+
type=semver,pattern={{version}}
72+
type=semver,pattern={{major}}.{{minor}}
73+
type=semver,pattern={{major}}
74+
3575
sourcegraph/scip-python:autoindex
3676
sourcegraph/scip-python:latest
3777
sourcegraph/scip-python:${{ github.ref_name }}
78+
79+
- name: Build and release image
80+
id: push
81+
uses: docker/build-push-action@v5
82+
with:
83+
context: images
84+
file: images/php.Dockerfile
85+
cache-from: type=gha,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }}
86+
cache-to: type=gha,mode=max,scope=docker-${{ matrix.version_debian}}-${{ matrix.version_python}}-${{ matrix.version_node }}
87+
push: true
88+
tags: ${{ steps.meta.outputs.tags }}
89+
labels: ${{ steps.meta.outputs.labels }}
90+
platforms: linux/amd64,linux/arm64
91+
build-args: |-
92+
VERSION_DEBIAN=${{ matrix.version_debian }}
93+
VERSION_PYTHON=${{ matrix.version_python }}
94+
VERSION_NODE=${{ matrix.version_node }}
95+
VERSION_SCIP_PYTHON=${{ github.ref_name }}
96+
97+
- name: Generate artifact attestation
98+
uses: actions/attest-build-provenance@v1
99+
with:
100+
subject-name: ${{ vars.REGISTRY || 'docker.io' }}/${{ github.repository }}
101+
subject-digest: ${{ steps.push.outputs.digest }}
102+
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)