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

View File

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

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>
Current Firefox, Chrome, Edge, Brave or Safari will work fine.
- 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_
@ -42,15 +42,41 @@ cd DOSee
# install dependencies & build
yarn # npm install
# serve dosee over port 8086
# serve DOSee over port 8086
yarn run serve # npm run serve
```
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
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>
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.
```bash
# re-build
# change to the repo directory
cd DOSee
# re-build DOSee
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