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 2de0e08
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 20 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"]
49 changes: 49 additions & 0 deletions .github/workflows/ci.docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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

- name: docker/buildx
run:
docker buildx build
--tags pkgxdev/pkgx
--platform linux/amd64,linux/arm64
--file .github/Dockerfile
.github

- 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
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 %}
9 changes: 6 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
console.error("pkgx: you may need to: ⌘⇧P workbench.action.reloadWindow")
}
} break
case 'install':
case 'install': {
await ensure_pantry()
await install(await Promise.all(opts.args.map(x => parse_pkg_str(x, {latest: 'ok'}))))
break
const pkgs = await Promise.all(opts.args.map(x => parse_pkg_str(x, {latest: 'ok'})))
const xopts = await parse_xopts({plus: [], minus: []}, flags.update)
await install(pkgs, xopts)
} break
case 'deintegrate':
await integrate('uninstall', opts)
break
Expand All @@ -92,6 +94,7 @@ export default async function({ flags, ...opts }: Args, logger_prefix?: string)
console.log(await shell_completion(opts.args).then(x => x.join(" ")))
break
case 'provider': {
await ensure_pantry()
const programs = await provider(opts.args)
console.log(programs.join(" "))
Deno.exit(programs.length ? 0 : 1)
Expand Down
2 changes: 2 additions & 0 deletions src/modes/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export default function(verbosity = 0) {
if (verbosity <= 0) {
// 10| 20| 30| 40| 50| 60| 70| | 80|
return undent`
blazingly fast pkg runner
usage:
pkgx [+pkg@x.y…] [program|path] [--] [arg…]
Expand Down
5 changes: 5 additions & 0 deletions src/modes/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default async function(pkgs: PackageRequirement[]) {

async function write(dst: Path, pkgs: PackageRequirement[]) {
for (const pkg of pkgs) {
if (pkg.project == 'pkgx.sh') {

continue
}

for (const program of await usePantry().project(pkg).provides()) {

// skip for now since we would require specific versions and we haven't really got that
Expand Down
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 2de0e08

Please sign in to comment.