Skip to content

Commit

Permalink
working deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
StefVdHaute committed Mar 31, 2024
1 parent 6c8c365 commit 1da0be8
Show file tree
Hide file tree
Showing 7 changed files with 926 additions and 778 deletions.
45 changes: 21 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
# pull base image
ARG NODE_VERSION=latest
FROM node:${NODE_VERSION} as build

# ---- Base Node ----
FROM node:lts AS base
# Create app directory
WORKDIR /app

# ---- Dependencies ----
FROM base AS dependencies
COPY ./simple-kimai-kiosk/package.json ./simple-kimai-kiosk/package-lock.json ./

# set node environment
ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV

# install dependencies
# install app dependencies including 'devDependencies'
RUN npm install

COPY ./simple-kimai-kiosk ./
# ---- Copy Files/Build ----
FROM dependencies AS build
WORKDIR /app
COPY ./simple-kimai-kiosk /app
# Build react/vue/angular bundle static files
RUN npm run build

RUN npx expo export -p web
# --- Release ----
FROM nginx:latest AS release
# Remove default nginx website
RUN rm -rf /usr/share/nginx/html/* # is this needed?

FROM nginx as production
# Copy static files from build stage to nginx
COPY --from=build /app/dist /usr/share/nginx/html/

# set data to use for Kimai integration
ARG KIMAI_URL
# CUSTOMER_NAME can be left blank if only one customer
ARG CUSTOMER_NAME
ARG PROJECT_NAME=Default
ENV KIMAI_URL $KIMAI_URL
ENV CUSTOMER_NAME $CUSTOMER_NAME
ENV PROJECT_NAME $PROJECT_NAME
# Copy nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf

RUN mkdir /app
COPY --from=build /app/dist /app
COPY ./nginx.conf /etc/nginx/nginx.conf
CMD ["nginx", "-g", "daemon off;"]
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '2.4'

services:
simple_kimai_kiosk:
image: simple_kimai_kiosk
simple-kimai-kiosk:
container_name: my-nginx-container
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:80"

volumes:
notused:
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:80"]
interval: 30s
timeout: 10s
retries: 3
4 changes: 2 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ http {
listen 80;
server_name localhost;
location / {
root /app;
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
try_files $uri $uri/ =404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
Expand Down
5 changes: 5 additions & 0 deletions simple-kimai-kiosk/API.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: use environment variables for HOST, PROJECT, ACTIVITY
// It's a pain to set up and i tried for several hours to get it working
// The docker containers had it but the code wouldn't read them, thanks react-native
let HOST = 'http://192.168.1.20:8001';
let PROJECT = 1;
let ACTIVITY = 1;
Expand All @@ -7,6 +10,7 @@ export async function ping(username, password) {
const response = await fetch(HOST + '/api/ping', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-AUTH-USER': username,
'X-AUTH-TOKEN': password,
}
Expand Down Expand Up @@ -46,6 +50,7 @@ export async function getActiveTimer(username, password) {
const response = await fetch(HOST + '/api/timesheets/active', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-AUTH-USER': username,
'X-AUTH-TOKEN': password
}
Expand Down
12 changes: 9 additions & 3 deletions simple-kimai-kiosk/components/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import React, { useState, useEffect } from 'react';
function Timer({ startTime }) {
const [timeElapsed, setTimeElapsed] = useState(0);

const updateTimer = () => {
const currentTime = new Date();
const elapsedTime = currentTime - startTime;
setTimeElapsed(elapsedTime);
};

useEffect(() => {
updateTimer();

const intervalId = setInterval(() => {
const currentTime = new Date();
const elapsedTime = currentTime - startTime;
setTimeElapsed(elapsedTime);
updateTimer();
}, 1000);

return () => clearInterval(intervalId);
Expand Down
Loading

0 comments on commit 1da0be8

Please sign in to comment.