Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple Docker example + doc #33

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:20

ENV USER node
ENV PORT 8080
EXPOSE ${PORT}
ENV WORDIR /app
WORKDIR ${WORDIR}

ENV UPLOAD_DIR "/upload"
ENV UPLOAD_TMP_DIR "/upload"
ENV MAX_FILE_SIZE 300
ENV TOKEN ""
ENV INDEX_FILE ""

# install dep
COPY package.json package-lock.json ${WORDIR}
RUN mkdir -p ${UPLOAD_DIR} ${UPLOAD_TMP_DIR} && \
chown -R ${USER} ${WORDIR} ${UPLOAD_DIR} ${UPLOAD_TMP_DIR} && \
chmod 700 ${WORDIR} ${UPLOAD_DIR} ${UPLOAD_TMP_DIR}

USER ${USER}
RUN npm install --no-fund --omit dev

# copy full app
COPY . ${WORDIR}

CMD node http-server-upload.js
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ until the next free port is found. This can be disabled, see below.

*Attention:* Already existing files will be overwritten on upload.

### Docker mode

You can just build a container image from this repository.

```sh
docker build -t http-server-upload .
```

Then run it without argument for default

```sh
docker run --rm -ti http-server-upload
```

Or you can override default values with environment variables (only UPLOAD_DIR, UPLOAD_TMP_DIR, MAX_FILE_SIZE, TOKEN and INDEX_FILE for now).
`UPLOAD_DIR` and `UPLOAD_TMP_DIR` are set to `/upload`. You may find it useful to mount a volume in this directory to keep uploaded files. Keep
in mind that this volume must be writeable by the `node` user. More complete example.

```sh
docker run --rm -ti -e PORT=9090 -e UPLOAD_DIR=/data -v myvolume:/data -p 80:9090 http-server-upload
```

### Arguments and environment variables

The optional configuration is done by command line arguments or environment variables.
Expand Down
Loading