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

feat: add dockerfile, update readme #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM bitnami/node:8.9.0-r0 as builder

# Create app directory
RUN mkdir -p /app/image-resizer
WORKDIR /app/image-resizer

RUN npm install -g tripviss/image-resizer --unsafe
RUN image-resizer new
RUN npm install --unsafe

FROM bitnami/node:8.9.0-r0-prod
RUN mkdir -p /app/image-resizer
WORKDIR /app/image-resizer
RUN npm install --global pm2 --unsafe
COPY --from=builder /app/image-resizer .
EXPOSE 3000

CMD ["node", "server.js"]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,23 @@ See [install docs for sharp](http://sharp.dimens.io/en/stable/install/) if you g
The gulp setup includes nodemon which runs the app nicely, restarting between code changes. `PORT` can be set in the `.env` file if you need to run on a port other than 3001.

Tests can be run with: `gulp test`

## Docker

Build the Docker image with

docker build -t image-resizer .

Run the docker container with built image above

docker run -d \
-e NODE_ENV='production' \
-e EXTERNAL_SOURCE_EXAMPLE='http://example.com/' \
-e PORT='3000' \
-e LOCAL_FILE_PATH='/app/image-resizer/node_modules/image-resizer' \
-p 3000:3000 image-resizer

In the example above, we proxy the images from `example.com` host. You
can try the below url in browser.

localhost:3000/eexample/path/to/external/image.jpg