Dockerfile is working.

This commit is contained in:
Ben Garrett 2021-06-15 13:38:48 +10:00
parent 630e191751
commit d8b95fb10b
3 changed files with 82 additions and 87 deletions

View File

@ -1,46 +1,42 @@
# DOSee Dockerfile to load an nginx webhost server # DOSee Dockerfile
#
# Instructions to build and run: # Instructions for use:
#
# docker build -t dosee .
# docker run --name dosee_app -i -p 8086:80 dosee
# #
# docker build --tag dosee:latest . # docker build --tag dosee:latest .
# docker run --name dosee_app --interactive --publish 8086:80 dosee:latest # docker run --name dosee_app --interactive --publish 8086:80 dosee:latest
# #
# Or in short form:
# docker build -t dosee .
# docker run --name dosee_app -i -p 8086:80 dosee
# #
# Instruction to remove and cleanup: # To remove and cleanup:
#
# docker stop dosee_app # docker stop dosee_app
# docker container rm dosee_app # docker container rm dosee_app
# docker image rm dosee # docker image rm dosee
# nginx stable is used due to its less frequent updates # Multi-stage Docker build to reduce the overall image size
# alpine is a tiny linux distribution # DOSee will be built in this temporary Node.JS image
FROM nginx:stable-alpine AS dosee FROM node:current-alpine AS build
LABEL net.dosee.description="DOSee - A MS-DOS emulator for the web"
COPY src/ /home/nginx/src # Install and update the build dependencies
COPY package.json workbox-config.js /home/nginx/ RUN apk update && \
apk add --update yarn && \
npm update --global npm
# install dependencies and build the site # Copy source files
RUN mkdir -p /home/nginx/src COPY . /dosee
WORKDIR /home/nginx/
RUN apk add --update nodejs npm && \
npm install --global yarn && \
yarn --production && \
cp -r /home/nginx/build/* /usr/share/nginx/html/
WORKDIR /usr/share/nginx/html/ # Compile and build DOSee
WORKDIR /dosee
RUN yarn install --audit --production
# cleanup to reduce the image from 250M down to 56M. # DOSee will be served on this permanent nginx image
RUN rm -R /home/nginx && \ # It should only ammount to around 50 MB in size
yarn cache clean && \ # The nginx stable image is used due to its less frequent updates
npm -g uninstall yarn && \ FROM nginx:stable-alpine
npm cache clean --force && \ LABEL net.dosee.description="DOSee an MS-DOS emulator for the web"
apk del nodejs npm && \
du -hs /
# optional cleanup # Copy DOSee from the build image to the nginx webroot
RUN rm /usr/share/nginx/html/*
# serve internally over HTTP port 80 COPY --from=build /dosee/build/ /usr/share/nginx/html
EXPOSE 80

View File

@ -1,27 +1,21 @@
# DOSee Docker compose to load an nginx webhost server # DOSee Docker compose
# #
# Run: docker-compose up -d # Run: docker compose up
# Access in a browser: http://localhost:8086 # Access in a browser: http://localhost:8086
# #
# Shell access: docker-compose exec web sh # Shell access: docker compose exec web sh
# Reset containers: docker-compose rm # Reset containers: docker compose rm
# Reset volumes: docker-compose down --volumes # Reset volumes docker compose down --volumes
version: "3.2" version: "3.9"
services: services:
web: web:
labels: labels:
net.dosee.description: "DOSee an MS-DOS emulator for the web" net.dosee.description: "DOSee an MS-DOS emulator for the web"
container_name: "dosee_web" container_name: "dosee_app"
# nginx stable is used due to its less frequent updates build: .
# alpine is a tiny linux distribution image: "dosee"
image: nginx:stable-alpine # expose nginx web port 80 as port 8086
# expose nginx web port 80 as port 8086 ports:
ports: - "8086:80"
- "8086:80"
volumes:
# bind your local cloned DOSee repo to nginx's html hosting path
- type: bind
source: ./src
target: /usr/share/nginx/html

View File

@ -26,9 +26,9 @@ DOSee is only a user interface and installation process for an incredible emulat
- A web browser that supports JavaScript ES6 (ECMAScript 2015).<br> - A web browser that supports JavaScript ES6 (ECMAScript 2015).<br>
Current Firefox, Chrome, Edge, Brave or Safari will work fine. Current Firefox, Chrome, Edge, Brave or Safari will work fine.
- A physical keyboard, as MS-DOS is a text-based operating system. - A physical keyboard, as MS-DOS is a text-based operating system.
- [Node.js](https://nodejs.org) with [yarn](https://yarnpkg.com) or [npm](https://www.npmjs.com). - [Node.js](https://nodejs.org) plus [yarn](https://yarnpkg.com)/[npm](https://www.npmjs.com) or [Docker](https://www.docker.com/get-started)
**DOSee runs over an HTTP server**, and it can not function using the `file:///` browser protocol. **DOSee runs over an HTTP server**, and it can not function over the `file:///` browser protocol.
### Instructions, _download, build and serve_ ### Instructions, _download, build and serve_
@ -42,15 +42,41 @@ cd DOSee
# install dependencies & build # install dependencies & build
yarn # npm install yarn # npm install
# serve dosee over port 8086 # serve DOSee over port 8086
yarn run serve # npm run serve yarn run serve # npm run serve
``` ```
Point a web browser to http://localhost:8086 Point a web browser to http://localhost:8086
### Docker container instructions
```bash
# clone DOSee
git clone https://github.com/bengarrett/DOSee.git
cd DOSee
# run the container (tap Ctrl-C to exit)
docker compose up
```
Point a web browser to http://localhost:8086
```bash
# alternative manual build and run
docker build -t dosee .
docker run --name dosee_app -i -p 8086:80 dosee
# clean up and remove
docker container rm dosee_app
docker image rm dosee
```
### Usage & customisations
[Are in the USAGE document](USAGE.md)
### Editing the JS or HTML ### Editing the JS or HTML
If you edit the source files in `src/` you will need to clear the application storage and unregister the service workers. If you edit the source files in `src/` you will need to clear the application storage and unregister the service workers in your web browser.
- In Chrome/Edge bring up the browser Dev Tools in using <kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>J</kbd>.<br> - In Chrome/Edge bring up the browser Dev Tools in using <kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>J</kbd>.<br>
Select the Application and Storage tab.<br> Select the Application and Storage tab.<br>
@ -62,33 +88,12 @@ If you edit the source files in `src/` you will need to clear the application st
Press the Unregister button. Press the Unregister button.
```bash ```bash
# re-build # change to the repo directory
cd DOSee
# re-build DOSee
yarn # npm run install yarn # npm run install
``` ```
### Docker container instructions
```bash
# clone DOSee
git clone https://github.com/bengarrett/DOSee.git
cd DOSee
# build
docker build -t dosee .
# serve dosee over port 8086, press Ctrl-C to exit
docker run --name dosee_app -i -p 8086:80 dosee
# cleanup and remove
docker container rm dosee_app
docker image rm dosee
```
Point a web browser to http://localhost:8086
### Usage & customisations
[Is in USAGE](USAGE.md)
### License ### License