A docker service to expose node/npm/yarn commands over http
1.7K
A docker service to expose node/npm/yarn commands over http
Github Repository: https://github.com/yannoff/docker-node-api/
WARNING: This is a work in progress
Modern web application frameworks such as symfony,
are often coupled with yarn or node for assets building and compiling.
As a consequence, those javascript libraries have to be installed in
the PHP container, which is, from the docker point of view, not the
best practice.
This project aims at separating the javascript part:
node, NPM or yarn commands are bundled in a dedicated container
which exposes an http API.
For instance,
curl http://0.0.0.0:5000/yarn+install
will issue a
yarn install
command in the node server container.
On the other hand, the PHP container will have alternative node, yarn & npm scripts,
acting as pass-thru to the API endpoint.
For instance:
#!/bin/bash
#
# /usr/bin/node script example
#
# Collect arguments to build the encoded URL
args=
while [ $# -gt 0 ]
do
args="${args}%20$1"
shift 1
done
# Here we assume the node-api service is named "node"
# The hostname must be changed to match the docker-compose.yaml services config
curl http://node:5000/node${args} 2>/dev/null
The config.json file allows fine-tuning on the API server.
| name | type | description |
|---|---|---|
| allowed-commands | list | List of the commands exposed to the API Any other command call will result in a 403 Forbidden response code. |
| port | int | The port the server will listen to (1) |
(1) Beware: this value must match the exposed port in the docker-compose.yaml config.
The API entrypoint server script.
A few sample files are provided:
To support kriswallsmith/assetic, the php and node services config must follow a few principles in the docker-compose.yaml:
working_dir must be the same in either containers/tmp path must be shared between the two containersLicensed under the MIT License
Content type
Image
Digest
Size
62.7 MB
Last updated
about 5 years ago
docker pull yannoff/node-api