Reputation: 2964
I currently use NGINX as reverse proxy for multiple web applications (virtual hosts) hosted on a Linux server. It also serves static files for the applications (eg big Javascripts, bitmaps, software downloads) directly.
Now I want to package each application into a docker image. But what do I do with the static files?
I can either serve these files from the applications (which is slower) or have another images per application with it's own NGINX just for the static files.
Any other ideas?
Upvotes: 0
Views: 185
Reputation: 41
Good news - you do pretty much exactly what you're already doing. Basically you'll use the Nginx official image and just copy the files into the appropriate directory.
The Dockerfile would look something like this for create-react-app (as an example):
FROM node:16-alpine as builder
RUN mkdir -p /app
WORKDIR /app
COPY package.json ./
RUN npm install
COPY ./ ./
RUN npm run build
from nginx:alpine
COPY --from=builder /app/build /usr/share/nginx/html
Hosting containers on cloud infrastructure can come with its challenges though. The company I work for, cycle.io, simplifies the process and would be a great place for you to deploy your containerized server.
Upvotes: 1