Skip to content

Commit 0473c4a

Browse files
Provide a single self-contained docker image, remove alpine (#389)
* Provide a single self-contained docker image, remove alpine * Release docker image on main branch builds as well * Add a note about upgrading docker version * Only publish to NPM on tags
1 parent 8880b60 commit 0473c4a

File tree

4 files changed

+51
-42
lines changed

4 files changed

+51
-42
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.github/workflows/release.yml

+13-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
tags:
66
- v*
7+
branches:
8+
- main
79

810
jobs:
911
release-image:
@@ -19,6 +21,7 @@ jobs:
1921
- run: yarn run build
2022
- run: du -h dist/src/main.js
2123
- run: npm publish --access public
24+
if: startsWith(github.ref, 'refs/tags/v')
2225
env:
2326
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
2427
- run: echo "PATCH=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
@@ -29,8 +32,17 @@ jobs:
2932
with:
3033
username: ${{ secrets.DOCKER_USERNAME }}
3134
password: ${{ secrets.DOCKER_PASSWORD }}
32-
- name: Build and push
35+
- name: Build and push snapshot
3336
id: docker_build
37+
if: github.ref == 'refs/heads/main'
38+
uses: docker/build-push-action@v3
39+
with:
40+
push: true
41+
tags: |
42+
sourcegraph/scip-typescript:latest-snapshot
43+
- name: Build and push tag
44+
id: docker_build
45+
if: startsWith(github.ref, 'refs/tags/v')
3446
uses: docker/build-push-action@v3
3547
with:
3648
push: true
@@ -39,10 +51,3 @@ jobs:
3951
sourcegraph/scip-typescript:${{ env.PATCH }}
4052
sourcegraph/scip-typescript:${{ env.MINOR }}
4153
sourcegraph/scip-typescript:${{ env.MAJOR }}
42-
- name: Build and push
43-
id: docker_build_autoindex
44-
uses: docker/build-push-action@v3
45-
with:
46-
file: Dockerfile.autoindex
47-
push: true
48-
tags: sourcegraph/scip-typescript:autoindex

Dockerfile

+37-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
1-
# Keep in sync with Dockerfile.autoindex
2-
FROM node:20.8.1-alpine3.18@sha256:1ccb0c0ded3b21cee95fe6b6ce1ac23bd6680c8f152cbfb3047d5d9ea490b098
1+
# When updating the version of the base container, please use the
2+
# SHA256 listed under 'Index digest' on Docker Hub,
3+
# not the 'Manifest digest'.
4+
#
5+
# This ensures that when pulling the container, Docker will detect
6+
# the platform and pull the correct image (if it exists)
7+
#
8+
# Alternate way of determining the Index digest using the docker CLI.
9+
#
10+
# $ docker buildx imagetools inspect node:22.12.0-slim
11+
# Name: docker.io/library/node:22.12.0-slim
12+
# MediaType: application/vnd.oci.image.index.v1+json
13+
# Digest: sha256:a4b757cd491c7f0b57f57951f35f4e85b7e1ad54dbffca4cf9af0725e1650cd8
14+
# And use this digest in FROM
15+
ARG base_sha=a4b757cd491c7f0b57f57951f35f4e85b7e1ad54dbffca4cf9af0725e1650cd8
316

4-
ARG TAG
17+
FROM node:22.12.0-slim@sha256:${base_sha}
518

6-
RUN apk add --no-cache git curl
19+
ENV NODE_OPTIONS=--max-old-space-size=4096
720

8-
RUN yarn global add npm yarn
21+
RUN apt update && \
22+
apt install -y git bash curl ca-certificates python3 make build-essential automake autoconf curl && \
23+
rm -rf /var/lib/apt/lists/* && \
24+
npm install -g n yarn pnpm --force
925

10-
RUN yarn global add @sourcegraph/scip-typescript@${TAG} @sourcegraph/src
26+
WORKDIR /app
1127

12-
CMD ["/bin/sh"]
28+
COPY . .
29+
RUN npm install && npm run build && npm install -g .
30+
31+
WORKDIR /src
32+
33+
RUN mv /usr/local/bin/yarn /usr/local/bin/actual-yarn
34+
COPY ./dev/lenient-yarn.sh /usr/local/bin/yarn
35+
36+
RUN mv /usr/local/bin/npm /usr/local/bin/actual-npm
37+
COPY ./dev/lenient-npm.sh /usr/local/bin/npm
38+
39+
RUN mv /usr/local/bin/n /usr/local/bin/actual-n
40+
COPY ./dev/lenient-n.sh /usr/local/bin/n
41+
42+
ENTRYPOINT ["scip-typescript"]

Dockerfile.autoindex

-27
This file was deleted.

0 commit comments

Comments
 (0)