Skip to content

Commit

Permalink
Feat arm64 (#16)
Browse files Browse the repository at this point in the history
* arm64 support.

* sync json.

* linux only.

* sync json.

* fix platform select.

* sync json.

* fix test

* platform

* fix return code.

* fix lib path.

* update docs.
  • Loading branch information
dojyorin authored Mar 18, 2024
1 parent c576e3a commit 49917c4
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 31 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/_push.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
},
"jobs": {
"push": {
"name": "push: ${{matrix.distro}}",
"name": "push: ${{matrix.distro}}/${{matrix.arch}}",
"runs-on": "ubuntu-latest",
"strategy": {
"fail-fast": true,
"matrix": {
"distro": [
"alpine",
"distroless"
],
"arch": [
"amd64",
"arm64"
]
}
},
Expand Down Expand Up @@ -50,7 +54,7 @@
"pull": true,
"no-cache": true,
"tags": "${{env.tag_f}},${{env.tag_d}}${{matrix.distro == 'distroless' && format(',{0},{1}', env.tag_v, env.tag_l) || ''}}",
"platforms": "linux/amd64",
"platforms": "linux/${{matrix.arch}}",
"context": "{{defaultContext}}:./src",
"file": "${{matrix.distro}}.dockerfile",
"build-args": "DENO_VERSION=${{inputs.deno_version}}"
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:
required: true
jobs:
push:
name: 'push: ${{matrix.distro}}'
name: 'push: ${{matrix.distro}}/${{matrix.arch}}'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
distro:
- alpine
- distroless
arch:
- amd64
- arm64
env:
tag_f: dojyorin/deno:${{matrix.distro}}-${{inputs.deno_version}}
tag_d: dojyorin/deno:${{matrix.distro}}
Expand All @@ -37,7 +40,7 @@ jobs:
pull: true
no-cache: true
tags: ${{env.tag_f}},${{env.tag_d}}${{matrix.distro == 'distroless' && format(',{0},{1}', env.tag_v, env.tag_l) || ''}}
platforms: linux/amd64
platforms: linux/${{matrix.arch}}
context: '{{defaultContext}}:./src'
file: ${{matrix.distro}}.dockerfile
build-args: DENO_VERSION=${{inputs.deno_version}}
10 changes: 7 additions & 3 deletions .github/workflows/_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
},
"jobs": {
"test": {
"name": "test: ${{matrix.distro}}",
"name": "test: ${{matrix.distro}}/${{matrix.arch}}",
"runs-on": "ubuntu-latest",
"strategy": {
"fail-fast": true,
"matrix": {
"distro": [
"alpine",
"distroless"
],
"arch": [
"amd64",
"arm64"
]
}
},
Expand All @@ -36,14 +40,14 @@
"pull": true,
"no-cache": true,
"tags": "${{github.sha}}",
"platforms": "linux/amd64",
"platforms": "linux/${{matrix.arch}}",
"context": "{{defaultContext}}:./src",
"file": "${{matrix.distro}}.dockerfile",
"build-args": "DENO_VERSION=${{inputs.deno_version}}"
}
}, {
"name": "test image",
"run": "docker run --rm --init ${{github.sha}} eval -p 'new Date()'"
"run": "docker run --rm --init --platform linux/${{matrix.arch}} ${{github.sha}} eval -p 'new Date()'"
}]
}
}
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ on:
required: true
jobs:
test:
name: 'test: ${{matrix.distro}}'
name: 'test: ${{matrix.distro}}/${{matrix.arch}}'
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
distro:
- alpine
- distroless
arch:
- amd64
- arm64
steps:
- name: clone repository
uses: actions/checkout@v4
Expand All @@ -26,9 +29,9 @@ jobs:
pull: true
no-cache: true
tags: ${{github.sha}}
platforms: linux/amd64
platforms: linux/${{matrix.arch}}
context: '{{defaultContext}}:./src'
file: ${{matrix.distro}}.dockerfile
build-args: DENO_VERSION=${{inputs.deno_version}}
- name: test image
run: docker run --rm --init ${{github.sha}} eval -p 'new Date()'
run: docker run --rm --init --platform linux/${{matrix.arch}} ${{github.sha}} eval -p 'new Date()'
6 changes: 3 additions & 3 deletions .github/workflows/cron.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cron",
"on": {
"schedule": [{
"cron": "0 6 * * *"
"cron": "0 0 * * *"
}]
},
"jobs": {
Expand All @@ -17,11 +17,11 @@
],
"steps": [{
"name": "compare dockerhub tag and deno latest version",
"run": "echo deno_latest=$(! curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '.results[].name' | grep -q ${{needs.fetch.outputs.deno_version}}; echo ${?}) >> ${GITHUB_OUTPUT}"
"run": "echo deno_latest=$(curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '.results[].name' | grep -q ${{needs.fetch.outputs.deno_version}}; echo ${?}) >> ${{github.output}}"
}]
},
"test": {
"if": "${{needs.compare.outputs.deno_latest == '1'}}",
"if": "${{needs.compare.outputs.deno_latest == 1}}",
"uses": "./.github/workflows/_test.yaml",
"with": {
"deno_version": "${{needs.fetch.outputs.deno_version}}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cron.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: cron
on:
schedule:
- cron: 0 6 * * *
- cron: 0 0 * * *
jobs:
fetch:
uses: ./.github/workflows/_fetch.yaml
Expand All @@ -12,9 +12,9 @@ jobs:
- fetch
steps:
- name: compare dockerhub tag and deno latest version
run: echo deno_latest=$(! curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '.results[].name' | grep -q ${{needs.fetch.outputs.deno_version}}; echo ${?}) >> ${GITHUB_OUTPUT}
run: echo deno_latest=$(curl -Ls https://registry.hub.docker.com/v2/repositories/dojyorin/deno/tags?page_size=100 | yq '.results[].name' | grep -q ${{needs.fetch.outputs.deno_version}}; echo ${?}) >> ${{github.output}}
test:
if: ${{needs.compare.outputs.deno_latest == '1'}}
if: ${{needs.compare.outputs.deno_latest == 1}}
uses: ./.github/workflows/_test.yaml
with:
deno_version: ${{needs.fetch.outputs.deno_version}}
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

The simple and small deno docker image.

This image is published on DockerHub and synchronized with latest version of [denoland/deno](https://github.com/denoland/deno) every day at `06:00` UTC.
This image is published on DockerHub and synchronized with latest version of [denoland/deno](https://github.com/denoland/deno) every day at `00:00` UTC.

Now, let's start using it!

- [`docker.io/dojyorin/deno`](https://hub.docker.com/r/dojyorin/deno)

# Tags

|OS|Tags|Arch|
|OS|Tag|Arch|
|:--|:--|:--|
|Distroless (default)|`latest` `vX.Y.Z` `distroless` `distroless-vX.Y.Z`|`amd64`|
|Alpine|`alpine` `alpine-vX.Y.Z`|`amd64`|
|[distroless](https://github.com/googlecontainertools/distroless) (default)|`latest` `vX.Y.Z` `distroless` `distroless-vX.Y.Z`|`amd64` `arm64`|
|[alpine](https://github.com/alpinelinux/docker-alpine)|`alpine` `alpine-vX.Y.Z`|`amd64` `arm64`|

# How to use
Easy to introduce in your project.

**Notes**
**Note**
- When starting container, be sure to add `--init` flag (`docker run`) or `init: true` property (`docker-compose.yml`) to avoid [PID1 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.

Expand All @@ -33,7 +33,7 @@ Easy to introduce in your project.
docker run --rm --init -it dojyorin/deno:latest

# Run script.
docker run --rm --init --restart always -p 0.0.0.0:1993:8000 -v ./src:/data:ro dojyorin/deno:latest run /data/main.ts
docker run --rm --init --restart always -p 0.0.0.0:5000:8000 -v $(pwd)/src:/data:ro dojyorin/deno:latest run /data/main.ts
```

**As compose**
Expand All @@ -44,7 +44,7 @@ services:
init: true
restart: always
ports:
- 0.0.0.0:1993:8000
- 0.0.0.0:5000:8000
volumes:
- ./src:/data:ro
command:
Expand Down
9 changes: 5 additions & 4 deletions src/alpine.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ FROM gcr.io/distroless/cc-debian12:latest AS cc

FROM alpine:latest AS sym

COPY --from=cc /lib/*-linux-gnu/ld-linux-* /usr/local/lib/
COPY --from=cc --chown=root:root --chmod=755 /lib/*-linux-gnu/ld-linux-* /usr/local/lib/

RUN mkdir /lib64
RUN ln -s /usr/local/lib/ld-linux-* /lib64/
RUN mkdir -p /tmp/lib
RUN ln -s /usr/local/lib/ld-linux-* /tmp/lib/

FROM alpine: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=sym --chown=root:root --chmod=755 /lib64 /lib64
COPY --from=sym --chown=root:root --chmod=755 /tmp/lib /lib
COPY --from=sym --chown=root:root --chmod=755 /tmp/lib /lib64

RUN sed -i -e 's|nobody:/|nobody:/home|' /etc/passwd && chown nobody:nobody /home

Expand Down
9 changes: 5 additions & 4 deletions src/distroless.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ FROM gcr.io/distroless/cc-debian12:latest AS cc

FROM alpine:latest AS sym

COPY --from=cc /lib/*-linux-gnu/ld-linux-* /usr/local/lib/
COPY --from=cc --chown=root:root --chmod=755 /lib/*-linux-gnu/ld-linux-* /usr/local/lib/

RUN mkdir /lib64
RUN ln -s /usr/local/lib/ld-linux-* /lib64/
RUN mkdir -p /tmp/lib
RUN ln -s /usr/local/lib/ld-linux-* /tmp/lib/

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=sym --chown=root:root --chmod=755 /lib64 /lib64
COPY --from=sym --chown=root:root --chmod=755 /tmp/lib /lib
COPY --from=sym --chown=root:root --chmod=755 /tmp/lib /lib64

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

0 comments on commit 49917c4

Please sign in to comment.