Skip to content

Commit

Permalink
chore: initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitdalal committed Apr 20, 2024
0 parents commit 41b8cdd
Show file tree
Hide file tree
Showing 9 changed files with 1,605 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- Summary: Put your summary here -->

## Changelog

42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 🚀 Deploy
on:
push:
branches:
- main
pull_request: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
actions: write
contents: read

jobs:
deploy:
name: 🚀 Deploy
runs-on: ubuntu-22.04
# only build/deploy branches on pushes
if: ${{ github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: 'fly.toml'
field: 'app'

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
run:
flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.DS_store

/build
/public/build
/server-build
.env

# Easy way to create temporary files/folders that won't accidentally be added to git
*.local.*
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20.11.1
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci

# Copy application code
COPY --link . .


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "start" ]
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for arpit-im-shortner on 2024-04-20T15:20:17-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'arpit-im-shortner'
primary_region = 'yyz'

[build]

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
40 changes: 40 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const express = require("express");

const app = express();
const port = 3000;

const URLS = {
website: "https://arpitdalal.dev",
blog: "https://blog.arpitdalal.dev",
github: "https://github.com/arpitdalal",
linkedin: "https://linkedin.com/in/arpitdalal",
};

app.get("/", (_, res) => {
res.redirect(301, URLS.website);
});

app.get("/b", (_, res) => {
res.redirect(301, URLS.blog);
});
app.get("/blog", (_, res) => {
res.redirect(301, URLS.blog);
});

app.get("/gh", (_, res) => {
res.redirect(301, URLS.github);
});
app.get("/github", (_, res) => {
res.redirect(301, URLS.github);
});

app.get("/in", (_, res) => {
res.redirect(301, URLS.linkedin);
});
app.get("/linkedin", (_, res) => {
res.redirect(301, URLS.linkedin);
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Loading

0 comments on commit 41b8cdd

Please sign in to comment.