Skip to content

Commit

Permalink
Improve image. (#5)
Browse files Browse the repository at this point in the history
* WIP: Invert exit code.

* WIP: difference with deno_docker

* WIP

* update.
  • Loading branch information
dojyorin committed Nov 28, 2023
1 parent 886c1fa commit 00c2a01
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/push.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
"run": "echo value=$(curl -Ls https://api.github.com/repos/denoland/deno/releases/latest | yq '.tag_name') >> ${{github.output}}"
}, {
"name": "compare dockerhub tag and deno latest version",
"run": "curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '\"v\" + .results[].name' | grep -q ${{steps.deno_v.outputs.value}}"
}, {
"if": "${{failure()}}",
"name": "detect latest version - ${{steps.deno_v.outputs.value}}",
"run": "true"
"run": "! curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '\"v\" + .results[].name' | grep -q ${{steps.deno_v.outputs.value}}"
}]
},
"build": {
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ jobs:
name: get deno latest version
run: echo value=$(curl -Ls https://api.github.com/repos/denoland/deno/releases/latest | yq '.tag_name') >> ${{github.output}}
- name: compare dockerhub tag and deno latest version
run: curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '"v" + .results[].name' | grep -q ${{steps.deno_v.outputs.value}}
- if: ${{failure()}}
name: detect latest version - ${{steps.deno_v.outputs.value}}
run: "true"
run: '! curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq ''"v" + .results[].name'' | grep -q ${{steps.deno_v.outputs.value}}'
build:
name: 'build: ${{matrix.distro}}'
runs-on: ubuntu-latest
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ This image is published on DockerHub and synchronized with latest version of [de
- Distroless: [dojyorin/deno:distroless](https://hub.docker.com/r/dojyorin/deno/tags?name=distroless) (default)
- Alpine: [dojyorin/deno:alpine](https://hub.docker.com/r/dojyorin/deno/tags?name=alpine)

# Usage
# How to use
Easy to introduce in your project.

**⚠Notes**
- When starting container, be sure to add `--init` flag (`docker run`) or `init: true` property (`docker-compose.yml`) to avoid [PID 1 Problem](https://www.docker.com/blog/keep-nodejs-rockin-in-docker/#:~:text=PID%201%20Problem).
** Notes**
- When starting container, be sure to add `--init` flag (`docker run`) or `init: true` property (`docker-compose.yml`) to avoid [PID 1 Problem](https://www.docker.com/blog/keep-nodejs-rockin-in-docker#:~:text=PID%201%20Problem).
- For security reasons, default runtime user is `nonroot` in distroless and `nobody` in other distributions.

**As single image**
Expand Down Expand Up @@ -50,4 +50,14 @@ FROM dojyorin/deno:latest
COPY /project/* /project/
EXPOSE 8000
CMD ["run", "/project/main.ts"]
```
```

# Difference with official image

This project was created to solve the problems faced by [deno_docker](https://github.com/denoland/deno_docker) official images.

- [tini](https://github.com/krallin/tini) is redundant
- Alpine dependent on third-party image
- Using old debian in Distroless (Uses 11, latest is 12)

If official images solve those issues, this project will be unnecessary...
6 changes: 2 additions & 4 deletions src/alpine.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ ENV LD_LIBRARY_PATH="/usr/local/lib"

COPY --from=deno --chown=root:root --chmod=755 /tmp/deno /usr/local/bin/
COPY --from=cc --chown=root:root --chmod=755 /lib/*-linux-gnu/* /usr/local/lib/
COPY --from=cc --chown=root:root --chmod=755 /lib64/* /lib64/

RUN mkdir /lib64 && \
ln -s /usr/local/lib/ld-linux-*.so.2 /lib64/ && \
sed -i -e 's|nobody:/|nobody:/home/nobody|' /etc/passwd && \
install -d -o nobody -g nobody -m 700 /home/nobody
RUN sed -i -e 's|nobody:/|nobody:/home/nobody|' /etc/passwd && install -d -o nobody -g nobody -m 700 /home/nobody

USER nobody
ENTRYPOINT ["/usr/local/bin/deno"]
8 changes: 7 additions & 1 deletion src/distroless.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ ARG DENO_VERSION
RUN apk --update --no-cache add curl
RUN curl -Ls https://github.com/denoland/deno/releases/download/${DENO_VERSION}/deno-$(arch)-unknown-linux-gnu.zip | unzip -q -d /tmp -

FROM gcr.io/distroless/cc-debian12:latest
FROM gcr.io/distroless/cc-debian12:latest AS cc

FROM gcr.io/distroless/static-debian12:latest

ENV LD_LIBRARY_PATH="/usr/local/lib"

COPY --from=deno --chown=root:root --chmod=755 /tmp/deno /usr/local/bin/
COPY --from=cc --chown=root:root --chmod=755 /lib/*-linux-gnu/* /usr/local/lib/
COPY --from=cc --chown=root:root --chmod=755 /lib64/* /lib64/

USER nonroot
ENTRYPOINT ["/usr/local/bin/deno"]

0 comments on commit 00c2a01

Please sign in to comment.