diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..264d4a71 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node:14-buster-slim AS builder + +# Install all OS dependencies +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update --yes && \ + apt-get upgrade --yes && \ + apt-get install --yes --no-install-recommends \ + build-essential + +# Copy over required files for build +WORKDIR /var/app +COPY config /var/app/config +COPY fixtures /var/app/fixtures +COPY public /var/app/public +COPY src /var/app/src +COPY .babelrc .env .eslintignore .eslintrc package-lock.json package.json /var/app/ + +# Build the app +RUN npm install +RUN npm run build + +# Serve the production build files via nginx (will be served at http://localhost:80/caravan) +FROM nginx:1.23 +COPY --from=builder /var/app/build /usr/share/nginx/html/caravan \ No newline at end of file diff --git a/README.md b/README.md index 4b080bb2..dc7811d6 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,22 @@ $ npm run build ... ``` +### Docker + +A basic dockerfile which builds the app and serves it via nginx is included in the repository + +To build the docker image: +```bash +docker build . -t caravan:latest +``` + +To run the built docker image: +```bash +docker run -p 80:8000 caravan:latest +``` + +Caravan should then be accessible at http://localhost:8000/caravan + ## Usage If you can access the [Caravan web