Skip to content

Commit

Permalink
Merge pull request #145 from WildCodeSchool/chore/add-img-to-github-a…
Browse files Browse the repository at this point in the history
…ctions

Chore/add img to GitHub actions
  • Loading branch information
Sojabio authored Dec 12, 2024
2 parents 6d34dd7 + 756a1b1 commit d6f1355
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/frontend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ jobs:
context: "{{defaultContext}}:backend"
file: Dockerfile.prod
tags: ${{ secrets.DOCKERHUB_USERNAME }}/wildrent-backend:latest, ${{ secrets.DOCKERHUB_USERNAME }}/wildrent-backend:${{ github.sha }}
- name: Build and push img
uses: docker/build-push-action@v4
with:
push: true
context: "{{defaultContext}}:img"
file: Dockerfile.prod
tags: ${{ secrets.DOCKERHUB_USERNAME }}/wildrent-img:latest, ${{ secrets.DOCKERHUB_USERNAME }}/wildrent-img:${{ github.sha }}

13 changes: 11 additions & 2 deletions img/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ const app = express();
const port = 4000;
app.use(cors());

const MIME_TYPES: Record<string, string> = {
"image/jpg": "jpg",
"image/jpeg": "jpg",
"image/png": "png"
};


const storage = multer.diskStorage({
destination: function (_req, _file, cb) {
cb(null, path.join(__dirname, "../uploads/"));
},
filename: function (_req, file, cb) {
cb(null, Date.now() + "-" + file.originalname);
const extension = MIME_TYPES[file.mimetype];
cb(null, Date.now() + '.' + extension);

},
});
const upload = multer({ storage: storage });
const upload = multer({ storage: storage });

app.get("/", (_req, res) => {
res.send("Healthcheck Okay");
Expand Down

0 comments on commit d6f1355

Please sign in to comment.