Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .github/workflows/make-test.yml

This file was deleted.

31 changes: 22 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
FROM alpine:3.20
LABEL maintainer sndsgd
FROM debian:trixie-slim AS build
ARG VERSION

ARG JARFILE_URL
RUN apt-get update && apt-get install -y \
build-essential curl gcc git gnupg nodejs openjdk-21-jdk-headless python3 zip

RUN apk add --update --no-cache curl openjdk11-jre \
&& curl ${JARFILE_URL} -o /opt/closure-compiler.jar \
&& chmod 0755 /opt/closure-compiler.jar \
&& echo -e "#!/bin/sh -e\nexec java -jar /opt/closure-compiler.jar \$@" > /usr/local/bin/closure-compiler \
&& chmod +x /usr/local/bin/closure-compiler
WORKDIR /opt
RUN curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-amd64.deb -o /tmp/bazelisk-amd64.deb \
&& dpkg -i /tmp/bazelisk-amd64.deb

ENTRYPOINT ["/usr/local/bin/closure-compiler"]
RUN git clone --depth=1 --branch ${VERSION} https://github.com/google/closure-compiler.git

WORKDIR /opt/closure-compiler

# use the tag from git (as opposed to ${VERSION}) to ensure we have the correct version
RUN GIT_TAG=$(git describe --tags --abbrev=0) && \
bazelisk build --define=COMPILER_VERSION=$GIT_TAG --verbose_failures //:compiler_uberjar_deploy.jar

# runtime image
FROM debian:trixie-slim
LABEL maintainer=sndsgd

RUN apt-get update && apt-get install --yes --no-install-recommends openjdk-21-jre-headless
COPY --from=build /opt/closure-compiler/bazel-bin/compiler_uberjar_deploy.jar /opt/closure-compiler.jar
ENTRYPOINT ["java", "-jar", "/opt/closure-compiler.jar"]
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ help:
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%s\033[0m~%s\n", $$1, $$2}' \
| column -s "~" -t

VERSION_URL ?= https://repo1.maven.org/maven2/com/google/javascript/closure-compiler/
VERSION_PATTERN ?= '(?<=>)[^/]+(?=/)'
VERSION_URL ?= https://github.com/google/closure-compiler/tags
VERSION_PATTERN ?= '/google/closure-compiler/releases/tag/v[0-9]+'
.PHONY: ensure-version
ensure-version:
ifeq ($(VERSION),)
$(info fetching latest version...)
@$(eval VERSION = $(shell curl -s $(VERSION_URL) | grep '<a href="v' | sort | tail -n 1 | grep -Po $(VERSION_PATTERN)))
@$(eval FETCHED_VERSION = $(VERSION))
$(eval VERSION = $(shell curl -s $(VERSION_URL) | grep -Po $(VERSION_PATTERN) | head -n 1 | sed 's|.*/tag/||'))
$(eval FETCHED_VERSION = $(VERSION))
endif
@$(eval JARFILE_URL := $(VERSION_URL)$(VERSION)/closure-compiler-$(VERSION).jar)
@$(eval IMAGE := $(IMAGE_NAME):$(VERSION))

IMAGE_ARGS ?= --quiet
Expand All @@ -35,9 +33,15 @@ image: ensure-version
$(info building image for closure compiler $(VERSION)...)
@docker build \
$(IMAGE_ARGS) \
--build-arg JARFILE_URL=$(JARFILE_URL) \
--build-arg VERSION=$(VERSION) \
--tag $(IMAGE) \
$(CWD)
@VERSION_OUTPUT=$$(docker run --rm $(IMAGE) --version | grep "Version: " | awk '{print $$2}' | tr -d '[:space:]'); \
if [ "$$VERSION_OUTPUT" != "$(VERSION)" ]; then \
echo "unexpected version: '$$VERSION_OUTPUT' (expected: $(VERSION))"; \
docker image rm $(IMAGE); \
exit 1; \
fi
ifeq ($(VERSION),$(FETCHED_VERSION))
@docker tag $(IMAGE) $(LATEST_IMAGE)
endif
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ docker run --rm \
-v "$(pwd)":"$(pwd)" \
-w "$(pwd)" \
ghcr.io/sndsgd/closure-compiler:latest \
--compilation_level=ADVANCED \
--language_out=ECMASCRIPT6_STRICT \
--summary_detail_level=10 \
--warning_level=VERBOSE \
--js="$(pwd)/path/to/src/**.js" \
--js="$(pwd)/path/to/entrypoint.js"
```
Expand Down
5 changes: 1 addition & 4 deletions tests/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ console.log(lib.foobar(lib.foobar("--")));
console.log(lib.kilogramsToPounds(100));

document.body.appendChild(lib.createDiv("help"))
document.body.appendChild(lib.createDiv("help1"))
document.body.appendChild(lib.createDiv("help2"))
document.body.appendChild(lib.createDiv("help3"))
document.body.appendChild(lib.createDiv("help4", "foo"))
document.body.appendChild(lib.createDiv("help", "pls"))