simplified docker builds

This commit is contained in:
undergroundwires
2020-07-14 17:59:21 +01:00
parent 909c44d72a
commit f27a2871d7
2 changed files with 12 additions and 20 deletions

View File

@@ -1,20 +1,12 @@
# +-+-+-+-+-+ +-+-+-+-+-+ # Build
# |B|u|i|l|d| |S|t|a|g|e|
# +-+-+-+-+-+ +-+-+-+-+-+
FROM node:lts-alpine as build-stage FROM node:lts-alpine as build-stage
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
RUN npm run build RUN npm run build
# For testing purposes, it's easy to run http-server on lts-alpine such as continuing from here:
# RUN npm install -g http-server
# EXPOSE 8080
# CMD [ "http-server", "dist" ]
# +-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+ # Production stage
# |P|r|o|d|u|c|t|i|o|n| |S|t|a|g|e|
# +-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+
FROM nginx:stable-alpine as production-stage FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80 EXPOSE 80

View File

@@ -28,16 +28,16 @@ Fork it & add more scripts in [application.yaml](src/application/application.yam
## Commands ## Commands
- Setup and run - Project setup: `npm install`
- For development: - Testing
- `npm install` to project setup. - Run unit tests: `npm run test:unit`
- `npm run serve` to compile & hot-reload for development. - Lint: `npm run lint`
- Production (using Docker): - **Webpage**
- Build `docker build -t undergroundwires/privacy.sexy .` - Development: `npm run serve` to compile & hot-reload for development.
- Run `docker run -it -p 8080:8080 --rm --name privacy.sexy-1 undergroundwires/privacy.sexy` - Production: `npm run build` to prepare files for distribution.
- Prepare for production: `npm run build` - Or run using Docker:
- Run tests: `npm run test:unit` 1. Build: `docker build -t undergroundwires/privacy.sexy:0.4.8 .`
- Lint and fix files: `npm run lint` 2. Run: `docker run -it -p 8080:80 --rm --name privacy.sexy-0.4.8 undergroundwires/privacy.sexy:0.4.8`
## Architecture ## Architecture