Skip to content

Commit

Permalink
Dockerfile created
Browse files Browse the repository at this point in the history
  • Loading branch information
Harduex committed Oct 30, 2021
1 parent 12c2e87 commit 5d3a185
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 2 deletions.
107 changes: 107 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# local config
config/local.ts
3 changes: 1 addition & 2 deletions App/Controllers/imageController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import config from "config";
import express, { Router } from "express";
import HttpStatusCode from "../Enums/HttpStatusCodes";
import checkAuthenticated from "../Helpers/middlewares/checkAuthenticated";
import uploadImage from "../Helpers/middlewares/uploadImage";
import { throwError } from "../Helpers/utilities/error";
import { deleteImage, getAllImages } from "../Services/imageService";
Expand All @@ -21,7 +20,7 @@ router.post("/upload", uploadImage.single("image"), async (req, res, next) => {
const folderName = config.get("storage.folderName");
const imageName = req.file?.filename;
const staticPath = `${folderName}/${imageName}`;
const fullUrl = req.protocol + "://" + req.get("host") + "/" + staticPath;
const fullUrl = `${req.protocol}://${config.get("server.host")}:${config.get("server.port")}/${staticPath}`;

return res.json({
filename: req.file?.filename,
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 6060
CMD ["npm", "start"]
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# images-cdn-service

Self hosted Node.js CDN for uploading and processing images for your web applications.

## docker example

```
sudo docker run -d -e HOST="your-host.com" -v ~/Desktop/images:/app/public/images -p 6060:6060 images-cdn
```
1 change: 1 addition & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ app.use(

// Utilities
app.use(express.static(path.join(__dirname, "public")));
app.use(express.urlencoded());
app.use(express.json());
app.use(morgan("dev"));

Expand Down
4 changes: 4 additions & 0 deletions config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export default {
corsOrigin: process.env.CORS_ORIGIN || "http://localhost:6060",
apiKey: process.env.API_KEY || "qQ5rVNU5eIo/DgEU8N1SRqvtc5fE2saSu+5DhzAQwXsmAC+xcTfI/YMe2wFSulCFPHqCiiQhVpg424IcQyEy9p62GpiAQp54udCGsSTF3mGatcj/AB59tF1Bf7N3pftSHm0XWVwWY/P/wpkOeeVL5fsKbWhFBvUqCjysnkb+fCFB8kLDZ/5xxzeQ1OkgTK5efNt4hC7VjKuoDTnF5Lx52GdbGEaHdbz4nMAXIN9s1Uu2GRIEn3EId58Jo9VLq1ZmouuGvZch4CXHdXcFIauLC8p0CSDPMzBWptTx05sUg6wWQXqE7UF8J4oCKiDXHF+QcDsYQVYjgzcpIY7wwFne1Q==",
},
storage : {
path: 'public',
folderName: 'images'
}
};

0 comments on commit 5d3a185

Please sign in to comment.