Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterxilo committed Oct 24, 2023
2 parents 83c0a12 + 3bbab2b commit 04c3609
Show file tree
Hide file tree
Showing 16 changed files with 2,274 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
dist/*
/node_modules
node_modules

build-in-container*
*.md
Dockerfile*
*.ps1
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ RUN npm install
COPY . ./
RUN ./build
RUN ls -l /app/dist/google-auth-library-token
RUN ldd /app/dist/google-auth-library-token
RUN ( /app/dist/google-auth-library-token || true ) 2>&1 | grep -F 'GOOGLE_APPLICATION_CREDENTIALS environment variable is not set!'

ENTRYPOINT [ "/app/dist/google-auth-library-token" ]
17 changes: 17 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:12-alpine

RUN apk add bash sudo curl
SHELL ["/bin/bash", "-c"]
RUN node --version

WORKDIR /app
COPY package*.json ./
RUN npm install

COPY . ./
RUN ./build
RUN ls -l /app/dist/google-auth-library-token-alpine
RUN ldd /app/dist/google-auth-library-token-alpine
RUN ( /app/dist/google-auth-library-token-alpine || true ) 2>&1 | grep -F 'GOOGLE_APPLICATION_CREDENTIALS environment variable is not set!'

ENTRYPOINT [ "/app/dist/google-auth-library-token" ]
24 changes: 24 additions & 0 deletions Dockerfile.alpine.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#FROM alpine:3.16

# includes libgcc
FROM node:12-alpine

# gcompat libstdc++: required for
#10 0.658 libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f9d72263000)
#10 0.658 libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f9d72249000)
# https://wiki.alpinelinux.org/wiki/Running_glibc_programs
RUN apk add bash sudo curl wget musl musl-dev gcompat libstdc++
SHELL ["/bin/bash", "-c"]

WORKDIR /app
COPY cachebust .
RUN wget https://github.com/Masterxilo/google-auth-library-token/raw/master/dist/google-auth-library-token-alpine
RUN chmod +x ./google-auth-library-token-alpine

# Error loading shared library libstdc++.so.6
RUN ldd ./google-auth-library-token-alpine
# TODO #10 1.662 /bin/bash: line 1: 8 Segmentation fault ./google-auth-library-token-alpine
RUN ( ./google-auth-library-token-alpine || true ) 2>&1
# | grep -F 'GOOGLE_APPLICATION_CREDENTIALS environment variable is not set!'

ENTRYPOINT [ "/app/dist/google-auth-library-token" ]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ npm install

[ ] the tool would be more useful if you could also pass the filename GOOGLE_APPLICATION_CREDENTIALS as a relative path as a commandline argument or even the contents of the file...

[x] alpine (musl) instead of glibc based version

# Tags
GOOGLE_APPLICATION_CREDENTIALS

Expand Down
6 changes: 6 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#!/bin/bash
set -euo pipefail

./npm-install-if-necessary

mkdir -p dist
rm dist/* || true

# depends on nodejs/npm
npm run package
ls

pushd dist
cp google-auth-library-token-win.exe google-auth-library-token.exe || true
cp google-auth-library-token.exe google-auth-library-token-win.exe || true

cp google-auth-library-token-linux google-auth-library-token || true
cp google-auth-library-token google-auth-library-token-linux || true

rm *-linux || true
rm *-win.exe || true
popd

ls dist
9 changes: 8 additions & 1 deletion build-in-container
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
set -euo pipefail

sudo docker build . --tag masterxilo/google-auth-library-token
# TODO use paulfrischknecht repo instead
TAG=masterxilo/google-auth-library-token
sudo docker build --progress plain --file Dockerfile . --tag $TAG

# note: the -alpine binary not built in alpine gives Segmentation fault in alpine!
rm dist/*-token dist/*-token.exe || true
sudo docker run --volume "$(pwd)/dist:/app/dist2" --entrypoint /bin/bash $TAG -c 'rm /app/dist/*-alpine ; cp /app/dist/* /app/dist2 ; echo "copied dist files" ; find /app/dist2'

9 changes: 9 additions & 0 deletions build-in-container.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

TAG=masterxilo/google-auth-library-token-alpine
#sudo docker build --progress plain --file Dockerfile.alpine . --tag $TAG

rm dist/*-alpine || true
sudo docker run --volume "$(pwd)/dist:/app/dist2" --entrypoint /bin/bash $TAG -c 'find /app/dist2 ; cp /app/dist/*-alpine /app/dist2 ; echo "copied alpine files" ; find /app/dist2'

Empty file added cachebust
Empty file.
Binary file modified dist/google-auth-library-token
Binary file not shown.
Binary file added dist/google-auth-library-token-alpine
Binary file not shown.
Binary file modified dist/google-auth-library-token.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions npm-install-if-necessary
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail

which npm

# npm install should also be run if package.json has been modified since last npm install run --> copy package.json to ./node_modules/package.json and compare!!!
if ! ls ./node_modules/package.json &> /dev/null || ! diff ./package.json ./node_modules/package.json &> /dev/null ; then
echo "npm install not run or outdated, running..." 1>&2
npm install 1>&2
cp ./package.json ./node_modules/package.json 1>&2
fi
Loading

0 comments on commit 04c3609

Please sign in to comment.