Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run as non root #606

Closed
wants to merge 13 commits into from
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.13.2-alpine AS BUILD_IMAGE
FROM node:16.14.2-alpine AS BUILD_IMAGE

# Set the platform to build image for
ARG TARGETPLATFORM
Expand All @@ -25,12 +25,15 @@ COPY . ./
RUN yarn build

# Production stage
FROM node:16.13.2-alpine
FROM node:16.14.2-alpine

# Define some ENV Vars
ENV PORT=80 \
ENV PORT=8080 \
DIRECTORY=/app \
IS_DOCKER=true
DEST_DIRECTORY=/app/dist \
IS_DOCKER=true \
UID=5000 \
GID=5000

# Create and set the working directory
WORKDIR ${DIRECTORY}
Expand All @@ -40,8 +43,14 @@ RUN apk add --no-cache tzdata tini

# Copy built application from build phase
COPY --from=BUILD_IMAGE /app ./
# Ensure only one version of conf.yml exists
RUN rm dist/conf.yml

# fix permissions
RUN rm -rf ${DEST_DIRECTORY} && \
mkdir ${DEST_DIRECTORY} && \
chown $UID:$GID ${DEST_DIRECTORY} && \
chmod 755 ${DEST_DIRECTORY}

USER ${UID}

# Finally, run start command to serve up the built application
ENTRYPOINT [ "/sbin/tini", "--" ]
Expand Down
45 changes: 29 additions & 16 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,35 @@
This article outlines how to get Dashy running in a development environment, and outlines the basics of the architecture.
If you're adding new features, you may want to check out the [Development Guides](./docs/development-guides.md) docs, for tutorials covering basic tasks.

- [Setting up the Development Environment](#setting-up-the-dev-environment)
- [Prerequisites](#prerequisites)
- [Running the App](#running-the-project)
- [Project Commands](#project-commands)
- [Environmental Variables](#environmental-variables)
- [Git Strategy](#git-strategy)
- [Flow](#git-flow)
- [Branches](#git-branch-naming)
- [Commit emojis](#commit-emojis)
- [PR Guidelines](#pr-guidelines)
- [Resources for Beginners](#resources-for-beginners)
- [App Info](#app-info)
- [Code Style Guide](#style-guide)
- [Application Structure](#application-structure)
- [Development Tools](#development-tools)
- [Misc / Notes](#notes)
- [Developing](#developing)
- [Setting up the Dev Environment](#setting-up-the-dev-environment)
- [Prerequisites](#prerequisites)
- [Running the Project](#running-the-project)
- [Project Commands](#project-commands)
- [Basics](#basics)
- [Development](#development)
- [Utils and Checks](#utils-and-checks)
- [Alternate Start Commands](#alternate-start-commands)
- [Notes](#notes)
- [Environmental Variables](#environmental-variables)
- [Environment Modes](#environment-modes)
- [Git Strategy](#git-strategy)
- [Git Flow](#git-flow)
- [Git Branch Naming](#git-branch-naming)
- [Commit Emojis](#commit-emojis)
- [PR Guidelines](#pr-guidelines)
- [Resources for Beginners](#resources-for-beginners)
- [App Info](#app-info)
- [Style Guide](#style-guide)
- [Application Structure](#application-structure)
- [Files in the Root: `./`](#files-in-the-root-)
- [Frontend Source: `./src/`](#frontend-source-src)
- [Visualisation of Source Directory](#visualisation-of-source-directory)
- [Development Tools](#development-tools)
- [Performance - Lighthouse](#performance---lighthouse)
- [Dependencies - BundlePhobia](#dependencies---bundlephobia)
- [Notes](#notes-1)
- [Known Warnings](#known-warnings)

## Setting up the Dev Environment

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"pm2-start": "npx pm2 start server.js",
"build-watch": "vue-cli-service build --watch --mode production",
"build-watch": "vue-cli-service build --watch --mode production --no-clean",
"build-and-start": "npm-run-all --parallel build-watch start",
"validate-config": "node services/config-validator",
"health-check": "node services/healthcheck",
Expand Down