lots of stuff
This commit is contained in:
parent
6868860a85
commit
992450e9d3
6 changed files with 43 additions and 2 deletions
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
FROM node:12
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
COPY . .
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "start"]
|
||||
|
|
@ -9,4 +9,11 @@ Note: I'm assuming you're running Ubuntu 22.04.
|
|||
* Get nodejs and npm ready
|
||||
- Run `sudo apt update` and `sudo apt install nodejs`. Check that worked with `node -v`.
|
||||
- Run `sudo apt install npm`. Check that worked with `npm -v`.
|
||||
* Init an npm project.
|
||||
* Init an npm project: `npm init -y`
|
||||
* Modify `package.json`: you might want to add dependencies.
|
||||
* Potentially add a `start script`.
|
||||
|
||||
## How to run
|
||||
|
||||
* You can get the dev containers up and running with `npm run start:containers`.
|
||||
* If you would rather only run the express app locally, you can just do `npm run start` instead.
|
||||
|
|
|
|||
3
caddy/Caddyfile
Normal file
3
caddy/Caddyfile
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
:80 {
|
||||
reverse_proxy express:3000
|
||||
}
|
||||
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
express:
|
||||
build: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
caddy:
|
||||
image: caddy:2
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./caddy:/etc/caddy
|
||||
depends_on:
|
||||
- express
|
||||
2
index.js
2
index.js
|
|
@ -3,7 +3,7 @@ const app = express();
|
|||
const port = 3000;
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World!');
|
||||
res.send("Hello World! We're live");
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"start:containers": "docker compose up -d --build",
|
||||
"stop:containers": "docker compose down",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue