mirror of https://github.com/lissy93/dashy
🔧 Change internal port to 8080, for non-sudo access
This commit is contained in:
parent
6a0fef6356
commit
39dbb4c4fc
136
Dockerfile
136
Dockerfile
|
@ -1,68 +1,68 @@
|
||||||
FROM node:16.13.2-alpine AS BUILD_IMAGE
|
FROM node:16.13.2-alpine AS BUILD_IMAGE
|
||||||
|
|
||||||
# Set the platform to build image for
|
# Set the platform to build image for
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
||||||
|
|
||||||
# Install additional tools needed if on arm64 / armv7
|
# Install additional tools needed if on arm64 / armv7
|
||||||
RUN \
|
RUN \
|
||||||
case "${TARGETPLATFORM}" in \
|
case "${TARGETPLATFORM}" in \
|
||||||
'linux/arm64') apk add --no-cache python3 make g++ ;; \
|
'linux/arm64') apk add --no-cache python3 make g++ ;; \
|
||||||
'linux/arm/v7') apk add --no-cache python3 make g++ ;; \
|
'linux/arm/v7') apk add --no-cache python3 make g++ ;; \
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create and set the working directory
|
# Create and set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
COPY package.json yarn.lock ./
|
COPY package.json yarn.lock ./
|
||||||
RUN yarn install --frozen-lockfile --network-timeout 1000000
|
RUN yarn install --frozen-lockfile --network-timeout 1000000
|
||||||
|
|
||||||
# Copy over all project files and folders to the working directory
|
# Copy over all project files and folders to the working directory
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
# Build initial app for production
|
# Build initial app for production
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:16.13.2-alpine
|
FROM node:16.13.2-alpine
|
||||||
|
|
||||||
# Define some ENV Vars
|
# Define some ENV Vars
|
||||||
ENV PORT=80 \
|
ENV PORT=8080 \
|
||||||
DIRECTORY=/app \
|
DIRECTORY=/app \
|
||||||
IS_DOCKER=true \
|
IS_DOCKER=true \
|
||||||
USER=docker \
|
USER=docker \
|
||||||
UID=12345 \
|
UID=12345 \
|
||||||
GID=23456
|
GID=23456
|
||||||
|
|
||||||
# Install tini for initialization and tzdata for setting timezone
|
# Install tini for initialization and tzdata for setting timezone
|
||||||
RUN apk add --no-cache tzdata tini \
|
RUN apk add --no-cache tzdata tini \
|
||||||
# Add group
|
# Add group
|
||||||
&& addgroup --gid ${GID} "${USER}" \
|
&& addgroup --gid ${GID} "${USER}" \
|
||||||
# Add user
|
# Add user
|
||||||
&& adduser \
|
&& adduser \
|
||||||
--disabled-password \
|
--disabled-password \
|
||||||
--ingroup "${USER}" \
|
--ingroup "${USER}" \
|
||||||
--gecos "" \
|
--gecos "" \
|
||||||
--home "${DIRECTORY}" \
|
--home "${DIRECTORY}" \
|
||||||
--no-create-home \
|
--no-create-home \
|
||||||
--uid "$UID" \
|
--uid "$UID" \
|
||||||
"$USER"
|
"$USER"
|
||||||
|
|
||||||
USER ${USER}
|
USER ${USER}
|
||||||
|
|
||||||
# Create and set the working directory
|
# Create and set the working directory
|
||||||
WORKDIR ${DIRECTORY}
|
WORKDIR ${DIRECTORY}
|
||||||
|
|
||||||
# Copy built application from build phase
|
# Copy built application from build phase
|
||||||
COPY --from=BUILD_IMAGE --chown=${USER}:${USER} /app ./
|
COPY --from=BUILD_IMAGE --chown=${USER}:${USER} /app ./
|
||||||
|
|
||||||
# Finally, run start command to serve up the built application
|
# Finally, run start command to serve up the built application
|
||||||
ENTRYPOINT [ "/sbin/tini", "--" ]
|
ENTRYPOINT [ "/sbin/tini", "--" ]
|
||||||
CMD [ "yarn", "build-and-start" ]
|
CMD [ "yarn", "build-and-start" ]
|
||||||
|
|
||||||
# Expose the port
|
# Expose the port
|
||||||
EXPOSE ${PORT}
|
EXPOSE ${PORT}
|
||||||
|
|
||||||
# Run simple healthchecks every 5 mins, to check that everythings still great
|
# Run simple healthchecks every 5 mins, to check that everythings still great
|
||||||
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check
|
HEALTHCHECK --interval=5m --timeout=2s --start-period=30s CMD yarn health-check
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
---
|
---
|
||||||
# Welcome to Dashy! To get started, run `docker compose up -d`
|
# Welcome to Dashy! To get started, run `docker compose up -d`
|
||||||
# You can configure your container here, by modifying this file
|
# You can configure your container here, by modifying this file
|
||||||
version: "3.8"
|
version: "3.8"
|
||||||
services:
|
services:
|
||||||
dashy:
|
dashy:
|
||||||
container_name: Dashy
|
container_name: Dashy
|
||||||
|
|
||||||
# Pull latest image from DockerHub
|
# Pull latest image from DockerHub
|
||||||
image: lissy93/dashy
|
image: lissy93/dashy
|
||||||
|
|
||||||
# To build from source, replace 'image: lissy93/dashy' with 'build: .'
|
# To build from source, replace 'image: lissy93/dashy' with 'build: .'
|
||||||
# build: .
|
# build: .
|
||||||
|
|
||||||
# Or, to use a Dockerfile for your archtecture, uncomment the following
|
# Or, to use a Dockerfile for your archtecture, uncomment the following
|
||||||
# context: .
|
# context: .
|
||||||
# dockerfile: ./docker/Dockerfile-arm32v7
|
# dockerfile: ./docker/Dockerfile-arm32v7
|
||||||
|
|
||||||
# You can also use an image with a different tag, or pull from a different registry, e.g:
|
# You can also use an image with a different tag, or pull from a different registry, e.g:
|
||||||
# image: ghcr.io/lissy93/dashy or image: lissy93/dashy:arm64v8
|
# image: ghcr.io/lissy93/dashy or image: lissy93/dashy:arm64v8
|
||||||
|
|
||||||
# Pass in your config file below, by specifying the path on your host machine
|
# Pass in your config file below, by specifying the path on your host machine
|
||||||
# volumes:
|
# volumes:
|
||||||
# - /path/to/my-config.yml:/app/public/conf.yml
|
# - /path/to/my-config.yml:/app/public/conf.yml
|
||||||
# - /path/to/item-icons:/app/public/item-icons
|
# - /path/to/item-icons:/app/public/item-icons
|
||||||
|
|
||||||
# Set port that web service will be served on. Keep container port as 80
|
# Set port that web service will be served on. Keep container port as 8080
|
||||||
ports:
|
ports:
|
||||||
- 4000:80
|
- 4000:8080
|
||||||
|
|
||||||
# Set any environmental variables
|
# Set any environmental variables
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
# Specify your user ID and group ID. You can find this by running `id -u` and `id -g`
|
# Specify your user ID and group ID. You can find this by running `id -u` and `id -g`
|
||||||
# - UID=1000
|
# - UID=1000
|
||||||
# - GID=1000
|
# - GID=1000
|
||||||
|
|
||||||
# Specify restart policy
|
# Specify restart policy
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# Configure healthchecks
|
# Configure healthchecks
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ['CMD', 'node', '/app/services/healthcheck']
|
test: ['CMD', 'node', '/app/services/healthcheck']
|
||||||
interval: 1m30s
|
interval: 1m30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 40s
|
start_period: 40s
|
||||||
|
|
|
@ -35,8 +35,8 @@ const ENDPOINTS = require('./src/utils/defaults').serviceEndpoints; // API endpo
|
||||||
/* Checks if app is running within a container, from env var */
|
/* Checks if app is running within a container, from env var */
|
||||||
const isDocker = !!process.env.IS_DOCKER;
|
const isDocker = !!process.env.IS_DOCKER;
|
||||||
|
|
||||||
/* Checks env var for port. If undefined, will use Port 80 for Docker, or 4000 for metal */
|
/* Checks env var for port. If undefined, will use Port 8080 for Docker, or 4000 for metal */
|
||||||
const port = process.env.PORT || (isDocker ? 80 : 4000);
|
const port = process.env.PORT || (isDocker ? 8080 : 4000);
|
||||||
|
|
||||||
/* Attempts to get the users local IP, used as part of welcome message */
|
/* Attempts to get the users local IP, used as part of welcome message */
|
||||||
const getLocalIp = () => {
|
const getLocalIp = () => {
|
||||||
|
|
|
@ -12,7 +12,7 @@ module.exports = (app) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDocker = !!process.env.IS_DOCKER;
|
const isDocker = !!process.env.IS_DOCKER;
|
||||||
const SSLPort = process.env.SSL_PORT || (isDocker ? 443 : 4001);
|
const SSLPort = process.env.SSL_PORT || (isDocker ? 8081 : 4001);
|
||||||
|
|
||||||
const printSuccess = () => {
|
const printSuccess = () => {
|
||||||
console.log(`🔐 HTTPS server successfully started (port: ${SSLPort} ${isDocker ? 'of container' : ''})`);
|
console.log(`🔐 HTTPS server successfully started (port: ${SSLPort} ${isDocker ? 'of container' : ''})`);
|
||||||
|
|
Loading…
Reference in New Issue