Created one Dockerfile for all platforms. Updated README file

This commit is contained in:
Paweł Malak
2021-11-18 16:30:04 +01:00
parent f501941a22
commit 0665e1274d
3 changed files with 72 additions and 53 deletions

View File

@@ -1,11 +1,12 @@
FROM node:14-alpine FROM node:14-alpine3.11 AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN apk --no-cache --virtual build-dependencies add python make g++ \
&& npm install
COPY . . COPY . .
# Install client dependencies # Install client dependencies
@@ -14,13 +15,22 @@ RUN mkdir -p ./public ./data \
&& npm install \ && npm install \
&& npm rebuild node-sass && npm rebuild node-sass
# Build # Build
RUN npm run build \ RUN npm run build \
&& mv ./client/build/* ./public && mv ./client/build/* ./public
# Clean up src files # Clean up src files
RUN rm -rf src/ ./client \ RUN rm -rf src/ ./client \
&& npm prune --production && npm prune --production \
&& apk del build-dependencies
FROM node:14-alpine
USER node
WORKDIR /app
COPY --from=builder /app /app
EXPOSE 5000 EXPOSE 5000

View File

@@ -1,11 +1,10 @@
FROM node:14-alpine FROM node:14-alpine AS builder
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN apk --no-cache --virtual build-dependencies add python make g++ \ RUN npm install
&& npm install
COPY . . COPY . .
@@ -21,8 +20,15 @@ RUN npm run build \
# Clean up src files # Clean up src files
RUN rm -rf src/ ./client \ RUN rm -rf src/ ./client \
&& npm prune --production \ && npm prune --production
&& apk del build-dependencies
FROM node:14-alpine
USER node
WORKDIR /app
COPY --from=builder /app /app
EXPOSE 5000 EXPOSE 5000

View File

@@ -6,62 +6,35 @@
Snippet Box is a simple self-hosted app for organizing your code snippets. It allows you to easily create, edit, browse and manage your snippets in various languages. With built-in Markdown support, Snippet Box makes it very easy to add notes or simple documentation to your code. Snippet Box is a simple self-hosted app for organizing your code snippets. It allows you to easily create, edit, browse and manage your snippets in various languages. With built-in Markdown support, Snippet Box makes it very easy to add notes or simple documentation to your code.
## Technology
- Backend
- Node.js
- Typescript
- Express.js
- Sequelize ORM + SQLite
- Frontend
- React
- TypeScript
- Bootstrap
- Deployment
- Docker
## Development
```sh
# clone repository
git clone https://github.com/pawelmalak/snippet-box
cd snippet-box
# install dependencies (run only once)
npm run init
# start backend and frontend development servers
npm run dev
```
## Installation ## Installation
### With Docker ### With Docker
#### Docker Hub #### Docker Hub
[Docker Hub image link](https://hub.docker.com/r/pawelmalak/snippet-box). [Docker Hub link](https://hub.docker.com/r/pawelmalak/snippet-box)
For arm platforms use `:arm` tag.
#### Building image
```sh ```sh
# Building image for Linux docker pull pawelmalak/snippet-box
docker build -t snippet-box .
# Build image for ARM
docker buildx build \
--platform linux/arm/v7,linux/arm64 \
-f Dockerfile.arm \
-t snippet-box:arm .
``` ```
#### Deployment #### Deployment
```sh ```sh
# run container # Create container
# for ARM use snippet-box:arm tag docker run -p 5000:5000 -v /path/to/host/data:/app/data pawelmalak/snippet-box
docker run -p 5000:5000 -v /path/to/data:/app/data snippet-box ```
#### Building image
```sh
# Building single image
docker build -t snippet-box .
# Building multiarch image
docker buildx build \
--platform linux/arm/v7,linux/arm64,linux/amd64 \
-t snippet-box .
``` ```
#### Docker Compose #### Docker Compose
@@ -83,6 +56,36 @@ services:
Follow instructions from wiki - [Installation without Docker](https://github.com/pawelmalak/snippet-box/wiki/Installation-without-Docker) Follow instructions from wiki - [Installation without Docker](https://github.com/pawelmalak/snippet-box/wiki/Installation-without-Docker)
## Development
### Technology
- Backend
- Node.js
- Typescript
- Express.js
- Sequelize ORM + SQLite
- Frontend
- React
- TypeScript
- Bootstrap
- Deployment
- Docker
### Creating dev environment
```sh
# clone repository
git clone https://github.com/pawelmalak/snippet-box
cd snippet-box
# install dependencies (run only once)
npm run init
# start backend and frontend development servers
npm run dev
```
## Functionality ## Functionality
- Search - Search