Skip to content

Commit

Permalink
Update Dockerfile and docker docs
Browse files Browse the repository at this point in the history
Closes #804
  • Loading branch information
mxcl committed Oct 12, 2023
1 parent 4a410f9 commit 7a50a06
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ RUN echo 'export PS1="\\[\\033[38;5;63m\\]pkgx\\[\\033[0m\\] $ "' >> /root/.bash
RUN pkgx integrate

FROM debian:buster-slim as stage1
RUN apt-get update && apt --yes install libc-dev libstdc++-8-dev libgcc-8-dev netbase libudev-dev
COPY --from=stage0 /usr/local/bin/pkgx /usr/local/bin/pkgx
COPY --from=stage0 /root/.bashrc /root/.bashrc
RUN apt-get update && apt --yes install libc-dev libstdc++-8-dev libgcc-8-dev netbase libudev-dev
CMD ["bash"]
ENV BASH_ENV /root/.bashrc
SHELL ["/bin/bash", "-c"]
CMD ["bash", "-i"]
52 changes: 52 additions & 0 deletions .github/workflows/ci.docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: ci·docker

on:
pull_request:
paths:
- .github/Dockerfile

concurrency:
group: ci/docker/${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
packages: write

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- run: |
mkdir products
curl https://pkgx.sh/$(uname)/$(uname -m).tgz | tar -xz -C products
- name: docker/buildx
run:
docker build
--tag pkgxdev/pkgx
--file .github/Dockerfile
.

- run: |
echo <<EoD> Dockerfile
FROM pkgxdev/pkgx
RUN env +duf && duf
RUN if which duf; then exit 1; fi
EoD
docker build --file Dockerfile .
- run: |
echo <<EoD> Dockerfile
FROM pkgxdev/pkgx
RUN echo '{}' > package.json
RUN dev && npm --version
RUN if which npm; then exit 1; fi
EoD
docker build --file Dockerfile .
2 changes: 1 addition & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
## Run Anywhere

* [`pkgx` & Terminals](run/anywhere/terminals.md)
* [`pkgx` & Scripting](run/anywhere/scripts.md)
* [`pkgx` & Docker](run/anywhere/docker.md)
* [`pkgx` & CI/CD](run/anywhere/ci-cd.md)
* [`pkgx` & Scripting](run/anywhere/scripts.md)
* [`pkgx` & Editors](run/anywhere/editors.md)


Expand Down
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pkgx is just another pkg so:

```
```sh
pkgx@latest npx@latest cowsay@latest 'fancy a cuppa?'
```

Expand Down
21 changes: 7 additions & 14 deletions docs/run/anywhere/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,23 @@ You can use this as a base:

```Dockerfile
FROM pkgxdev/pkgx
RUN env +node@16
RUN npm start
RUN pkgx +node@16 npm start
```

Or if you want to use `pkgx` in another image:

```Dockerfile
FROM archlinux
RUN eval "$(curl -Ssf --proto '=https' https://pkgx.sh)"
RUN env +node@16
RUN npm start
```

`eval`ing our one-liner also integrates `pkgx` with the container’s shell.
If you don’t want that you can `curl -Ssf pkgx.sh | sh` instead:

```Dockerfile
FROM archlinux
RUN curl -Ssf --proto '=https' https://pkgx.sh
RUN curl -Ssf --proto '=https' https://pkgx.sh | sh
RUN pkgx +node@16 npm start
```


{% hint style="success" %}
We have binaries for Linux aarch64 (arm64) thus Docker on your Apple Silicon
Mac is as fast and easy as deployments.
{% endhint %}

{% hint style="warning" %}
At this time our shellcode doesn’t work in Docker, but we are working on
making `pkgx` able to be a proxy shell for these situations.
{% endhint %}
3 changes: 3 additions & 0 deletions src/modes/shellcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function() {
rm "${tmp}/shellcode/"?.$$
else
echo "pkgx: nothing to run" >&2
return 1
fi;;
*)
command pkgx -- "$@";;
Expand Down Expand Up @@ -110,6 +111,8 @@ export default function() {
for arg in "$@"; do
printf "%q " "$arg" >> "$d/x.$$"
done
return 127
else
echo "cmd not found: $1" >&2
return 127
Expand Down

0 comments on commit 7a50a06

Please sign in to comment.