Skip to content

Instantly share code, notes, and snippets.

View sagar290's full-sized avatar
🏠
Working from home

Sagar sagar290

🏠
Working from home
View GitHub Profile
@sagar290
sagar290 / entrypoint.sh
Created April 2, 2022 17:05
golang entrypoint.sh
#!/bin/sh
set -e
if [ ${APP_ENV} = 'local' ];
then
echo "not in production"
cd /src && air
else
echo "in production"
(cd /src/) && (go build main.go) && (/src/./main)
@sagar290
sagar290 / Dockerfile
Last active April 2, 2022 17:01
dockerfile for golang with live reloding
FROM golang:1.16-alpine as build
RUN apk add --no-cache git
RUN go get -v github.com/cosmtrek/air
WORKDIR /src
COPY . /src
@sagar290
sagar290 / Dockerfile
Created February 18, 2022 14:48 — forked from Machy8/Dockerfile
PHP-FPM 7.1 with Unix Sockets + Nginx in Docker
FROM debian:stretch
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
zip \
git \
unzip && \
rm -rf /var/lib/apt/lists/* && \
apt-get clean
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-express-deployment
labels:
app: mongo-express
spec:
replicas: 2
selector:
matchLabels:
# start octane in production if DOCKER_APP_ENV is not development
if [ ${DOCKER_APP_ENV} = 'development' ];
then
echo "Octane is not ready"
php /var/www/html/artisan serve
else
echo "Octane is ready"
php /var/www/html/artisan octane:start
fi
@sagar290
sagar290 / docker-compose.yml
Created November 14, 2021 17:45
run laravel docker with supervisor
version: '3.7'
services:
app:
image: app
build:
context: .
dockerfile: ./docker/Dockerfile
args:
- PHP_VERSION=${PHP_VERSION:-7.4}
# user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
server {
# Set the port to listen on and the server name
listen 80;
# Set the document root of the project
root /var/www/app/public;
# Set the directory index files
index index.php index.html index.htm;
fields := reflect.VisibleFields(reflect.TypeOf(struct{ employeeDetails }{}))
for _, field := range fields {
fmt.Printf("Key: %s\tType: %s\n", field.Name, field.Type)
}
func getAttr(obj interface{}, fieldName string) reflect.Value {
pointToStruct := reflect.ValueOf(obj) // addressable
curStruct := pointToStruct.Elem()
if curStruct.Kind() != reflect.Struct {
panic("not struct")
}
curField := curStruct.FieldByName(fieldName) // type: reflect.Value
if !curField.IsValid() {
panic("not found:" + fieldName)
}