lots of stuff

This commit is contained in:
counterweight 2025-02-05 13:21:00 +01:00
parent 6868860a85
commit 992450e9d3
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
6 changed files with 43 additions and 2 deletions

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM node:12
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

View file

@ -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
View file

@ -0,0 +1,3 @@
:80 {
reverse_proxy express:3000
}

16
docker-compose.yml Normal file
View 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

View file

@ -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, () => {

View file

@ -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": [],