Skip to content

Commit

Permalink
Rewrote it in node, no more php
Browse files Browse the repository at this point in the history
  • Loading branch information
C4illin committed Feb 26, 2024
1 parent daa9629 commit c099337
Show file tree
Hide file tree
Showing 32 changed files with 1,336 additions and 915 deletions.
4 changes: 0 additions & 4 deletions .env.example

This file was deleted.

12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Custom

/public/js*
/public/images*
/public/css*
/public/mix-manifest.json
/frontend/public/js*
/frontend/public/images*
/frontend/public/css*
/frontend/public/mix-manifest.json

# Created by https://www.toptal.com/developers/gitignore/api/node,macos,linux,windows,visualstudiocode,yarn,composer
# Edit at https://www.toptal.com/developers/gitignore?templates=node,macos,linux,windows,visualstudiocode,yarn,composer

### Composer ###
composer.phar
/vendor/
frontend/composer.phar
frontend/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
33 changes: 11 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
FROM node:20 as node-build
FROM node:20
ENV NODE_ENV=production

WORKDIR /app
WORKDIR /app/frontend

COPY package*.json ./
COPY frontend/package*.json ./
RUN npm install

COPY . .
COPY frontend/ ./
RUN npm run production

FROM composer:2 as composer-build
WORKDIR /app
WORKDIR /app/backend

COPY composer.json composer.lock ./
RUN composer install --no-dev


FROM php:8.2-apache as run

RUN docker-php-ext-install mysqli pdo pdo_mysql

COPY --from=node-build /app/public /var/www/html
COPY --from=composer-build /app/vendor /var/www/vendor
COPY app /var/www/app


WORKDIR /var/www/html
COPY backend/package*.json ./
RUN npm install

RUN chown -R www-data:www-data /var/www/
COPY backend/ ./

EXPOSE 80
EXPOSE 3000
CMD ["node", "index.js"]
31 changes: 0 additions & 31 deletions app/db.php

This file was deleted.

13 changes: 0 additions & 13 deletions app/index.php

This file was deleted.

59 changes: 0 additions & 59 deletions app/mix.php

This file was deleted.

31 changes: 31 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import express from 'express';
import mc from "minecraftstatuspinger";
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

const app = express();
const port = 3000;
const currentFilePath = fileURLToPath(import.meta.url);
const currentDirPath = dirname(currentFilePath);

// use public
app.use(express.static('../frontend/public'));

app.get('/', (req, res) => {
const filePath = path.join(currentDirPath, 'views', 'home.html');
res.sendFile(filePath);
});

app.get('/ping', async (_, res) => {
try {
let result = await mc.lookup({ host: "mc.chs.se" });
res.send(result);
} catch (error) {
res.status(500).send("An error occurred while pinging the server.");
}
});

app.listen(port, () => {
console.log(`App listening at http://localhost:${port}`);
});
Loading

0 comments on commit c099337

Please sign in to comment.