Skip to content
Snippets Groups Projects
Dockerfile 749 B
Newer Older
FROM node:16.13.0-alpine
ARG API_URL
Esko Ikkala's avatar
Esko Ikkala committed

# Based on https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
# Create app directory
WORKDIR /usr/src/app
Esko Ikkala's avatar
Esko Ikkala committed

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
COPY webpack*.js ./

# Babel 7 presets and plugins
COPY babel.config.js ./
Esko Ikkala's avatar
Esko Ikkala committed
# Bundle app source
esikkala's avatar
esikkala committed
# Run the scripts defined in package.json
RUN npm install && \ 
API_URL=$API_URL npm run build
Esko Ikkala's avatar
Esko Ikkala committed

EXPOSE 3001

# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
USER node

esikkala's avatar
esikkala committed
# Express server handles the backend functionality and also serves the React app
CMD ["node", "/usr/src/app/dist/server"]