Skip to content

Commit 0665e12

Browse files
committed
Created one Dockerfile for all platforms. Updated README file
1 parent f501941 commit 0665e12

File tree

3 files changed

+71
-52
lines changed

3 files changed

+71
-52
lines changed

‎Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
FROM node:14-alpine
1+
FROM node:14-alpine3.11 AS builder
22

33
WORKDIR /app
44

55
COPY package*.json ./
66

7-
RUN npm install
8-
7+
RUN apk --no-cache --virtual build-dependencies add python make g++ \
8+
&& npm install
9+
910
COPY . .
1011

1112
# Install client dependencies
@@ -14,13 +15,22 @@ RUN mkdir -p ./public ./data \
1415
&& npm install \
1516
&& npm rebuild node-sass
1617

17-
# Build
18+
# Build
1819
RUN npm run build \
1920
&& mv ./client/build/* ./public
2021

2122
# Clean up src files
2223
RUN rm -rf src/ ./client \
23-
&& npm prune --production
24+
&& npm prune --production \
25+
&& apk del build-dependencies
26+
27+
FROM node:14-alpine
28+
29+
USER node
30+
31+
WORKDIR /app
32+
33+
COPY --from=builder /app /app
2434

2535
EXPOSE 5000
2636

‎Dockerfile.arm renamed to ‎Dockerfile.dev

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
FROM node:14-alpine
1+
FROM node:14-alpine AS builder
22

33
WORKDIR /app
44

55
COPY package*.json ./
66

7-
RUN apk --no-cache --virtual build-dependencies add python make g++ \
8-
&& npm install
7+
RUN npm install
98

109
COPY . .
1110

@@ -21,8 +20,15 @@ RUN npm run build \
2120

2221
# Clean up src files
2322
RUN rm -rf src/ ./client \
24-
&& npm prune --production \
25-
&& apk del build-dependencies
23+
&& npm prune --production
24+
25+
FROM node:14-alpine
26+
27+
USER node
28+
29+
WORKDIR /app
30+
31+
COPY --from=builder /app /app
2632

2733
EXPOSE 5000
2834

‎README.md

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,35 @@
66

77
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.
88

9-
## Technology
10-
11-
- Backend
12-
- Node.js
13-
- Typescript
14-
- Express.js
15-
- Sequelize ORM + SQLite
16-
- Frontend
17-
- React
18-
- TypeScript
19-
- Bootstrap
20-
- Deployment
21-
- Docker
9+
## Installation
2210

23-
## Development
11+
### With Docker
2412

25-
```sh
26-
# clone repository
27-
git clone https://github.com/pawelmalak/snippet-box
28-
cd snippet-box
13+
#### Docker Hub
2914

30-
# install dependencies (run only once)
31-
npm run init
15+
[Docker Hub link](https://hub.docker.com/r/pawelmalak/snippet-box)
3216

33-
# start backend and frontend development servers
34-
npm run dev
17+
```sh
18+
docker pull pawelmalak/snippet-box
3519
```
3620

37-
## Installation
38-
39-
### With Docker
40-
41-
#### Docker Hub
21+
#### Deployment
4222

43-
[Docker Hub image link](https://hub.docker.com/r/pawelmalak/snippet-box).
44-
For arm platforms use `:arm` tag.
23+
```sh
24+
# Create container
25+
docker run -p 5000:5000 -v /path/to/host/data:/app/data pawelmalak/snippet-box
26+
```
4527

4628
#### Building image
4729

4830
```sh
49-
# Building image for Linux
31+
# Building single image
5032
docker build -t snippet-box .
5133

52-
# Build image for ARM
34+
# Building multiarch image
5335
docker buildx build \
54-
--platform linux/arm/v7,linux/arm64 \
55-
-f Dockerfile.arm \
56-
-t snippet-box:arm .
57-
```
58-
59-
#### Deployment
60-
61-
```sh
62-
# run container
63-
# for ARM use snippet-box:arm tag
64-
docker run -p 5000:5000 -v /path/to/data:/app/data snippet-box
36+
--platform linux/arm/v7,linux/arm64,linux/amd64 \
37+
-t snippet-box .
6538
```
6639

6740
#### Docker Compose
@@ -83,6 +56,36 @@ services:
8356
8457
Follow instructions from wiki - [Installation without Docker](https://github.com/pawelmalak/snippet-box/wiki/Installation-without-Docker)
8558
59+
## Development
60+
61+
### Technology
62+
63+
- Backend
64+
- Node.js
65+
- Typescript
66+
- Express.js
67+
- Sequelize ORM + SQLite
68+
- Frontend
69+
- React
70+
- TypeScript
71+
- Bootstrap
72+
- Deployment
73+
- Docker
74+
75+
### Creating dev environment
76+
77+
```sh
78+
# clone repository
79+
git clone https://github.com/pawelmalak/snippet-box
80+
cd snippet-box
81+
82+
# install dependencies (run only once)
83+
npm run init
84+
85+
# start backend and frontend development servers
86+
npm run dev
87+
```
88+
8689
## Functionality
8790

8891
- Search

0 commit comments

Comments
 (0)