Skip to content

Instantly share code, notes, and snippets.

View ivorscott's full-sized avatar

Ivor Scott Cummings ivorscott

View GitHub Profile
@ivorscott
ivorscott / docker-compose-traefik.yaml
Last active August 9, 2023 14:59 — forked from prayagsingh/docker-compose-traefik.yaml
Traefik with file provider and with letsencrypt and custom tls certs
# Providers :- discover the services that live on your infrastructure (their IP, health, ...)
# Entrypoints :- listen for incoming traffic (ports, ...)
# Routers :- analyse the requests (host, path, headers, SSL, ...). A router is in charge of connecting incoming requests to the services that can handle them.
# Services :- forward the request to your services (load balancing, ...). The Services are responsible for configuring how to reach the actual services that will eventually handle the incoming requests.
# Middlewares :- may update the request or make decisions based on the request (authentication, rate limiting, headers, ...)
version: "3.7"
networks:
API_PORT=4000
PPROF_PORT=6060
CLIENT_PORT=3000
DB_URL=postgres://postgres:postgres@db:5432/postgres?sslmode=disable
REACT_APP_BACKEND=https://localhost:4000/v1
API_WEB_FRONTEND_ADDRESS=https://localhost:3000
mkdir -p ./api/tls
go run $(go env GOROOT)/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost
mv *.pem ./api/tls
-- 000001_create_products_table.up.sql
CREATE TABLE products (
id UUID not null unique,
name varchar(100) not null,
price real not null,
description varchar(100) not null,
created timestamp without time zone default (now() at time zone 'utc')
);
-- 000001_create_products_table.down.sql
DROP TABLE IF EXISTS products;
-- 000002_add_tags_to_products.up.sql
ALTER TABLE products
ADD COLUMN tags varchar(255);
-- 000002_add_tags_to_products.down.sql
ALTER TABLE products
DROP Column tags;
-- ./api/internal/schema/seeds/products.sql
INSERT INTO products (id, name, price, description, created) VALUES
('cbef5139-323f-48b8-b911-dc9be7d0bc07','Xbox One X', 499.00, 'Eighth-generation home video game console developed by Microsoft.','2019-01-01 00:00:01.000001+00'),
('ce93a886-3a0e-456b-b7f5-8652d2de1e8f','Playstation 4', 299.00, 'Eighth-generation home video game console developed by Sony Interactive Entertainment.','2019-01-01 00:00:01.000001+00'),
('faa25b57-7031-4b37-8a89-de013418deb0','Nintendo Switch', 299.00, 'Hybrid console that can be used as a stationary and portable device developed by Nintendo.','2019-01-01 00:00:01.000001+00')
ON CONFLICT DO NOTHING;
export API_DB_DISABLE_TLS=true
cd api
go run ./cmd/api
# or go run ./cmd/api --db-disable-tls=true
debug-api_1 | 2020-06-04T20:21:18Z info layer=debugger created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x9ebf4a, Addrs:[]uint64{0x9ebf4a}, File:"/api/cmd/api/internal/handlers/products.go", Line:23,
FunctionName:"github.com/ivorscott/go-delve-reload/cmd/api/internal/handlers.(*Products).List", Cond:"", Tracepoint:false, TraceReturn:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil),
LoadArgs:(*api.LoadConfig)(0xc0010d8180), LoadLocals:(*api.LoadConfig)(0xc0010d81b0), HitCount:map[string]uint64{}, TotalHitCount:0x0}