diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2705e11..97bf6c83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,8 @@ on: push: tags: - v* + branches: + - main jobs: release-image: @@ -19,6 +21,7 @@ jobs: - run: yarn run build - run: du -h dist/src/main.js - run: npm publish --access public + if: startsWith(github.ref, 'refs/tags/v') env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - run: echo "PATCH=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV @@ -29,8 +32,17 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push + - name: Build and push snapshot id: docker_build + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@v3 + with: + push: true + tags: | + sourcegraph/scip-typescript:latest-snapshot + - name: Build and push tag + id: docker_build + if: startsWith(github.ref, 'refs/tags/v') uses: docker/build-push-action@v3 with: push: true @@ -39,10 +51,3 @@ jobs: sourcegraph/scip-typescript:${{ env.PATCH }} sourcegraph/scip-typescript:${{ env.MINOR }} sourcegraph/scip-typescript:${{ env.MAJOR }} - - name: Build and push - id: docker_build_autoindex - uses: docker/build-push-action@v3 - with: - file: Dockerfile.autoindex - push: true - tags: sourcegraph/scip-typescript:autoindex diff --git a/Dockerfile b/Dockerfile index 2b9a5e65..df416edc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,42 @@ -# Keep in sync with Dockerfile.autoindex -FROM node:20.8.1-alpine3.18@sha256:1ccb0c0ded3b21cee95fe6b6ce1ac23bd6680c8f152cbfb3047d5d9ea490b098 +# When updating the version of the base container, please use the +# SHA256 listed under 'Index digest' on Docker Hub, +# not the 'Manifest digest'. +# +# This ensures that when pulling the container, Docker will detect +# the platform and pull the correct image (if it exists) +# +# Alternate way of determining the Index digest using the docker CLI. +# +# $ docker buildx imagetools inspect node:22.12.0-slim +# Name: docker.io/library/node:22.12.0-slim +# MediaType: application/vnd.oci.image.index.v1+json +# Digest: sha256:a4b757cd491c7f0b57f57951f35f4e85b7e1ad54dbffca4cf9af0725e1650cd8 +# And use this digest in FROM +ARG base_sha=a4b757cd491c7f0b57f57951f35f4e85b7e1ad54dbffca4cf9af0725e1650cd8 -ARG TAG +FROM node:22.12.0-slim@sha256:${base_sha} -RUN apk add --no-cache git curl +ENV NODE_OPTIONS=--max-old-space-size=4096 -RUN yarn global add npm yarn +RUN apt update && \ + apt install -y git bash curl ca-certificates python3 make build-essential automake autoconf curl && \ + rm -rf /var/lib/apt/lists/* && \ + npm install -g n yarn pnpm --force -RUN yarn global add @sourcegraph/scip-typescript@${TAG} @sourcegraph/src +WORKDIR /app -CMD ["/bin/sh"] +COPY . . +RUN npm install && npm run build && npm install -g . + +WORKDIR /src + +RUN mv /usr/local/bin/yarn /usr/local/bin/actual-yarn +COPY ./dev/lenient-yarn.sh /usr/local/bin/yarn + +RUN mv /usr/local/bin/npm /usr/local/bin/actual-npm +COPY ./dev/lenient-npm.sh /usr/local/bin/npm + +RUN mv /usr/local/bin/n /usr/local/bin/actual-n +COPY ./dev/lenient-n.sh /usr/local/bin/n + +ENTRYPOINT ["scip-typescript"] diff --git a/Dockerfile.autoindex b/Dockerfile.autoindex deleted file mode 100644 index 94e11631..00000000 --- a/Dockerfile.autoindex +++ /dev/null @@ -1,27 +0,0 @@ -# Keep in sync with default Dockerfile -FROM node:20.8.1-alpine3.18@sha256:1ccb0c0ded3b21cee95fe6b6ce1ac23bd6680c8f152cbfb3047d5d9ea490b098 - -ENV NODE_OPTIONS=--max-old-space-size=4096 - -RUN apk add --no-cache git bash curl ca-certificates python3 make libstdc++ libgcc gcc g++ pkgconfig automake autoconf curl - -# The following line is kept for legacy reasons. We previously invoke the -# `scip-typescript-autoindex` script during auto-indexing in order to handle -# SCIP->LSIF conversion. This script is no longer needed since src handles the -# conversion. -RUN echo 'scip-typescript "$@" --no-progress-bar' > /usr/bin/scip-typescript-autoindex && chmod +x /usr/bin/scip-typescript-autoindex - -RUN yarn global add npm yarn n - -RUN yarn global add @sourcegraph/scip-typescript@${TAG} @sourcegraph/src - -RUN mv /usr/local/bin/yarn /usr/local/bin/actual-yarn -COPY ./dev/lenient-yarn.sh /usr/local/bin/yarn - -RUN mv /usr/local/bin/npm /usr/local/bin/actual-npm -COPY ./dev/lenient-npm.sh /usr/local/bin/npm - -RUN mv /usr/local/bin/n /usr/local/bin/actual-n -COPY ./dev/lenient-n.sh /usr/local/bin/n - -CMD ["/bin/sh"]