Last active
May 22, 2023 12:49
-
-
Save jayaregalinada/9d370dc66ab00d39fd14d08ae0241952 to your computer and use it in GitHub Desktop.
Vite in Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The express application | |
import express from 'express'; | |
import history from 'connect-history-api-fallback'; | |
const app = express(); | |
app.use(history()); | |
// Other middleware | |
app.use(express.static(path.join(__dirname, 'public'))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dockerfile for the Frontend server | |
// Image: company/frontend-server | |
FROM node:lts-alpine | |
ENV PORT 80 | |
WORKDIR /var/www/html | |
COPY src/package.json . | |
COPY src/package-lock.json . | |
COPY src . | |
RUN npm install -g pm2 | |
RUN npm install --no-dev | |
EXPOSE $PORT | |
CMD ["pm2-runtime", "/var/www/html/bin/www.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dockerfile for Vite app | |
FROM node:lts-alpine as build | |
COPY package.json . | |
COPY npm-lock.json . | |
# Install dependencies | |
RUN npm install | |
COPY . /tmp | |
# Build project | |
RUN npm run build | |
FROM company/frontend-server:the-version | |
// Copy generated Vite App and move it in the node frontend-server | |
COPY --from=build /tmp/dist /var/www/html/public |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment