Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tokens #55

Open
wants to merge 93 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
57fc6f3
Ignore temporary project files
zitryss Dec 10, 2021
2d7ea60
Use docker compose v2
zitryss Dec 11, 2021
510ede0
Use canonical header key
zitryss Dec 14, 2021
2969c25
Implement temporary links
zitryss Dec 15, 2021
02e4193
Hide image ID by using temporary links
zitryss Dec 19, 2021
d8e26e0
Use http.NoBody
zitryss Dec 19, 2021
15f9b00
Uppercase constants
zitryss Dec 19, 2021
1ee56df
Log application name
zitryss Dec 19, 2021
54497f9
Stop using LimitReader
zitryss Dec 19, 2021
c1f3317
Switch to the right endpoint
zitryss Dec 20, 2021
a47bbc7
Fix loadtest parameters
zitryss Dec 20, 2021
8033b88
Fix log output
zitryss Dec 20, 2021
16345de
Mimic minio
zitryss Dec 20, 2021
c3fd153
Grow buffer before use
zitryss Dec 21, 2021
5742f2c
Pass an internal interface
zitryss Dec 22, 2021
f8827af
Attach instructions on how to close file
zitryss Dec 22, 2021
45f17b4
Provide health endpoint
zitryss Dec 26, 2021
795bfeb
Use std contants
zitryss Dec 26, 2021
4eadc49
Test health endpoint
zitryss Dec 28, 2021
be2b8fc
Test edge cases
zitryss Dec 29, 2021
ca9db6d
Check health
zitryss Dec 30, 2021
202aa03
Change configuration method
zitryss Jan 4, 2022
6fa9fa2
Correct tests
zitryss Jan 10, 2022
8fc4c63
Fix redis rate limiting
zitryss Jan 10, 2022
d3039fc
Assign IP addresss correctly
zitryss Jan 10, 2022
7f4a5f7
Watch config files
zitryss Jan 11, 2022
7a1dc04
Clean up logs
zitryss Jan 14, 2022
68f7e08
Remove files from coverage report
zitryss Jan 14, 2022
f22aba7
Return always a protective header
zitryss Jan 14, 2022
6e4384a
Adjust config files
zitryss Jan 15, 2022
1df2e5e
Update loadtest tool
zitryss Jan 21, 2022
621b684
Change api name
zitryss Jan 22, 2022
637fdba
Change JSON response
zitryss Jan 22, 2022
a19a91a
Check interfaces
zitryss Jan 23, 2022
3fb5c4f
Stop rerouting requests
zitryss Jan 23, 2022
29213fc
Set unlimited ulimit
zitryss Jan 25, 2022
ed643df
Make checks consistent
zitryss Jan 25, 2022
dac1c80
Use init function for unlimit
zitryss Jan 26, 2022
9efb361
Replace manual checks with asserts
zitryss Jan 29, 2022
0dc3a56
Stop using log package for init function
zitryss Jan 30, 2022
c89bfe2
Use assert package where possible
zitryss Feb 1, 2022
18ad93c
Reset state
zitryss Feb 2, 2022
f88ab1a
Write helper id generator
zitryss Feb 3, 2022
4439ab7
Return helper function to compare files
zitryss Feb 3, 2022
a962da5
Generate IDs for the tests
zitryss Feb 7, 2022
8a71310
Refactor controller tests
zitryss Feb 9, 2022
76512a5
Set sane default settings
zitryss Feb 9, 2022
b801d27
Apply testing suits
zitryss Feb 10, 2022
3e74711
Refactor
zitryss Feb 10, 2022
14fecdc
Use one factory
zitryss Feb 11, 2022
b60d583
Minimize database tests
zitryss Feb 13, 2022
54b50ce
Optimize storage tests
zitryss Feb 13, 2022
62c0ae6
Optimize compressor tests
zitryss Feb 13, 2022
1be20dc
Test cache in a suite
zitryss Feb 14, 2022
bc3290a
Remove deadlock in testing
zitryss Feb 16, 2022
edf2adc
Use optimized library
zitryss Feb 16, 2022
401b046
Remove gobuild directive
zitryss Feb 16, 2022
322fc54
Minor improvements
zitryss Feb 23, 2022
6b4b14d
Various small changes
zitryss Mar 16, 2022
1ca093b
Various test related improvements
zitryss Mar 17, 2022
390ec55
Parallelize tests
zitryss Mar 17, 2022
56304ff
Tune GOGC in runtime
zitryss Mar 22, 2022
355b5f5
Deploy
zitryss Mar 24, 2022
e2cb2ec
Check key for existence
zitryss Mar 25, 2022
f5b52a6
Use transactions
zitryss Mar 25, 2022
804e038
Add Tx parameter
zitryss Mar 25, 2022
519195e
Upgrade to 1.18
zitryss Mar 25, 2022
9e2e871
Update go mod
zitryss Mar 25, 2022
5863402
Fix scope
zitryss Mar 27, 2022
b0a0809
Test improvements
zitryss Mar 28, 2022
273ce8a
Replace interface{} with any
zitryss Mar 29, 2022
06682a4
Update GcTuner tests
zitryss Mar 29, 2022
59f75ec
Random improvements
zitryss Mar 30, 2022
3d043c8
Refactor middleware
zitryss Mar 30, 2022
9b4cdd8
Assign request id
zitryss Apr 4, 2022
3383d0a
Test context
zitryss Apr 4, 2022
24b258b
Jsonify logs
zitryss Jun 11, 2022
4c9b847
Add comment on how to start a fuzz test
zitryss Jul 19, 2022
04f125b
Check for the nil context
zitryss Jul 19, 2022
2f18ffb
Cache CORS
zitryss Sep 22, 2022
88c8e1f
Structure logging
zitryss Oct 8, 2022
b691fe6
Update go version
zitryss Oct 8, 2022
a832609
Present Go GC tuner
zitryss Nov 2, 2022
8eee215
Modify ulimit package
zitryss Nov 2, 2022
b96b98f
Test logging
zitryss Nov 2, 2022
4a0b8d5
Update packages
zitryss Nov 2, 2022
143e1f6
Improve test parallelism
zitryss Nov 2, 2022
661a59f
Merge pull request #54 from zitryss/feature/remove-tokens
zitryss Dec 7, 2022
5b9208a
Update GitHub actions
zitryss Dec 7, 2022
a205dd6
Update GitHub cache action
zitryss Dec 7, 2022
010e38b
Fix GitHub cache action
zitryss Dec 7, 2022
4c059b4
Fix GitHub cache action
zitryss Dec 8, 2022
32d7d0a
Extend vscode python features with continue
zitryss Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/.git/
healthcheck
aye-and-nay
coverage.txt
/badger/
/build/badger/
/build/caddy/
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/cache@v2
go-version: 1.19
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
# Module download cache
# Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- run: make dev-up
- env:
CONTINUOUS_INTEGRATION: "true"
run: make test-int-ci
- run: make dev-down
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
files: ./coverage.txt
14 changes: 9 additions & 5 deletions .github/workflows/loadtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ jobs:
loadtest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/cache@v2
go-version: 1.19
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
# Module download cache
# Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- run: make prod-up
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/cache@v2
go-version: 1.19
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
# Module download cache
# Build cache (Linux)
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- run: make test-unit-ci
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
files: ./coverage.txt
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*.test

# aye-and-nay
main
healthcheck
aye-and-nay
coverage.txt
/badger/
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.analysis.extraPaths": [
"/Users/mercury/.vscode/extensions/continue.continue-0.0.412-darwin-arm64"
],
"python.autoComplete.extraPaths": [
"/Users/mercury/.vscode/extensions/continue.continue-0.0.412-darwin-arm64"
]
}
33 changes: 18 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
.PHONY: gen compile test-unit test-int test-unit-ci test-int-ci dev-up dev-down prod-loadtest prod-up prod-down embed-loadtest embed-up embed-down
.PHONY: gen compile compile-health test-unit test-int test-unit-ci test-int-ci dev-up dev-down prod-loadtest prod-up prod-down embed-loadtest embed-up embed-down

gen:
go install github.com/mailru/easyjson/easyjson@latest
go install golang.org/x/tools/cmd/stringer@latest
go install github.com/mailru/easyjson/easyjson
go install golang.org/x/tools/cmd/stringer
go generate ./...

compile: gen
CGO_ENABLED=0 go build -ldflags="-s -w"

compile-health:
CGO_ENABLED=0 go build -ldflags="-s -w" -o healthcheck ./cmd/healthcheck/main.go

test-unit: gen
go test -v -race -shuffle=on -count=1 -short -tags=unit -cover ./...
go test -v -race -shuffle=on -count=2 -short -cover ./... -args -unit

test-int: gen
go test -v -race -shuffle=on -count=1 -short -tags=integration -cover ./...
go test -v -race -shuffle=on -count=2 -short -cover ./... -args -int

test-unit-ci: gen
go test -v -race -shuffle=on -count=1 -tags=unit -failfast -coverprofile=coverage.txt -covermode=atomic ./...
go test -v -race -shuffle=on -count=2 -failfast -coverprofile=coverage.txt -covermode=atomic ./... -args -unit -ci

test-int-ci: gen
go test -v -race -shuffle=on -count=1 -tags=integration -failfast -coverprofile=coverage.txt -covermode=atomic ./...
go test -v -race -shuffle=on -count=2 -failfast -coverprofile=coverage.txt -covermode=atomic ./... -args -int -ci

dev-up:
docker-compose --file ./build/docker-compose-dev.yml up -d --build
docker compose --file ./build/docker-compose-dev.yml up -d --build

dev-down:
docker-compose --file ./build/docker-compose-dev.yml down --rmi all -v
docker compose --file ./build/docker-compose-dev.yml down --rmi all -v

prod-loadtest:
go run ./cmd/loadtest/main.go -verbose=false
go run ./cmd/loadtest/* -verbose=false

prod-up:
docker-compose --file ./build/docker-compose-prod.yml up -d --build
docker compose --file ./build/docker-compose-prod.yml --env-file ./build/config-prod.env up -d --build

prod-down:
docker-compose --file ./build/docker-compose-prod.yml down --rmi all -v
docker compose --file ./build/docker-compose-prod.yml --env-file ./build/config-prod.env down --rmi all -v

embed-loadtest:
go run ./cmd/loadtest/main.go -verbose=false -api-address "http://localhost:8001" -minio-address ""
go run ./cmd/loadtest/* -verbose=false -api-address="http://localhost:8001" -html=false

embed-up:
docker-compose --file ./build/docker-compose-embed.yml up -d --build
docker compose --file ./build/docker-compose-embed.yml --env-file ./build/config-embed.env up -d --build

embed-down:
docker-compose --file ./build/docker-compose-embed.yml down --rmi all -v
docker compose --file ./build/docker-compose-embed.yml --env-file ./build/config-embed.env down --rmi all -v
4 changes: 4 additions & 0 deletions build/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ localhost {
# www.aye-and-nay.de {
# redir https://aye-and-nay.de{uri} permanent
# }

:8080 {
respond /health 200
}
11 changes: 9 additions & 2 deletions build/Dockerfile-app
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
FROM golang:1.17-alpine AS builder
FROM golang:1.19-alpine AS builder
RUN apk add --no-cache make
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app/
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make compile
RUN make compile compile-health

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/
COPY --from=builder /app/aye-and-nay /
COPY --from=builder /app/config.env /
COPY --from=builder /app/healthcheck /
USER appuser
ENTRYPOINT ["/aye-and-nay"]
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD ["/healthcheck"]
6 changes: 6 additions & 0 deletions build/Dockerfile-caddy
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
FROM caddy:2-alpine
COPY ./build/Caddyfile /etc/caddy/Caddyfile
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
13 changes: 13 additions & 0 deletions build/Dockerfile-imaginary
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
FROM h2non/imaginary:1
USER root
RUN \
apt-get update && \
apt-get install --no-install-recommends --yes curl && \
apt-get autoremove --yes && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER nobody
ENV PORT=9001
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD curl -f http://localhost:9001/health || exit 1
5 changes: 5 additions & 0 deletions build/Dockerfile-minio
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
FROM minio/minio:RELEASE.2021-11-24T23-19-33Z
ENV MINIO_ROOT_USER=12345678 MINIO_ROOT_PASSWORD=qwertyui
CMD ["server", "/data", "--console-address", ":9090"]
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD curl -f http://localhost:9000/minio/health/live || exit 1
6 changes: 6 additions & 0 deletions build/Dockerfile-mongo
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
FROM mongo:5
COPY ./build/mongo.js /docker-entrypoint-initdb.d/mongo.js
ENV MONGO_INITDB_DATABASE=aye-and-nay
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD test $(echo 'db.runCommand("ping").ok' | mongo --quiet) -eq 1 || exit 1
6 changes: 6 additions & 0 deletions build/Dockerfile-redis
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
FROM redis:6-alpine
COPY ./build/redis.conf /usr/local/etc/redis/redis.conf
CMD ["redis-server", "/usr/local/etc/redis/redis.conf"]
HEALTHCHECK \
--interval=1m \
--timeout=30s \
--retries=3 \
CMD test $(redis-cli ping) = "PONG" || exit 1
2 changes: 2 additions & 0 deletions build/Dockerfile-swagger
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
FROM swaggerapi/swagger-ui:v4.1.2
COPY ./build/swagger.yml /swagger.yml
ENV SWAGGER_JSON=/swagger.yml
93 changes: 93 additions & 0 deletions build/config-dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# CONFIG
CONFIG_RELOAD=true
CONFIG_RELOAD_INTERVAL=1s

# APP
APP_NAME=config-dev
APP_LOG=info
APP_GC_TUNER=custom # [none, custom, go]
APP_MEM_TOTAL=2147483648 # 2 GB
APP_MEM_LIMIT_RATIO=0.7

# SERVER
SERVER_DOMAIN=
SERVER_HOST=localhost
SERVER_PORT=8001
SERVER_H2C=false
SERVER_READ_TIMEOUT=60s
SERVER_WRITE_TIMEOUT=120s
SERVER_IDLE_TIMEOUT=120s
SERVER_SHUTDOWN_TIMEOUT=10s

# MIDDLEWARE
MIDDLEWARE_CORS_ALLOW_ORIGIN=*
MIDDLEWARE_LIMITER_REQUESTS_PER_SECOND=30000
MIDDLEWARE_LIMITER_BURST=300
MIDDLEWARE_DEBUG=true

# CONTROLLER
CONTROLLER_MAX_NUMBER_OF_FILES=100
CONTROLLER_MAX_FILE_SIZE=5242880 # 5 MB

# SERVICE
SERVICE_TEMP_LINKS=true
SERVICE_NUMBER_OF_WORKERS_CALC=8
SERVICE_NUMBER_OF_WORKERS_COMP=8
SERVICE_ACCURACY=0.625

# CACHE: [mem, redis]
APP_CACHE=redis
CACHE_MEM_CLEANUP_INTERVAL=15m
CACHE_REDIS_HOST=localhost
CACHE_REDIS_PORT=6379
CACHE_REDIS_RETRY_TIMES=4
CACHE_REDIS_RETRY_PAUSE=5s
CACHE_REDIS_TIMEOUT=30s
CACHE_REDIS_TIME_TO_LIVE=15m
CACHE_REDIS_TX_RETRIES=5

# COMPRESSOR: [mock, shortpixel, imaginary]
APP_COMPRESSOR=mock
COMPRESSOR_SHORTPIXEL_URL=https://api.shortpixel.com/v2/post-reducer.php
COMPRESSOR_SHORTPIXEL_URL2=https://api.shortpixel.com/v2/reducer.php
COMPRESSOR_SHORTPIXEL_API_KEY=abcdefghijklmnopqrst
COMPRESSOR_SHORTPIXEL_RETRY_TIMES=2
COMPRESSOR_SHORTPIXEL_RETRY_PAUSE=10s
COMPRESSOR_SHORTPIXEL_TIMEOUT=30s
COMPRESSOR_SHORTPIXEL_WAIT=30
COMPRESSOR_SHORTPIXEL_UPLOAD_TIMEOUT=60s
COMPRESSOR_SHORTPIXEL_DOWNLOAD_TIMEOUT=60s
COMPRESSOR_SHORTPIXEL_REPEAT_IN=10s
COMPRESSOR_SHORTPIXEL_RESTART_IN=15m
COMPRESSOR_IMAGINARY_HOST=localhost
COMPRESSOR_IMAGINARY_PORT=9001
COMPRESSOR_IMAGINARY_RETRY_TIMES=4
COMPRESSOR_IMAGINARY_RETRY_PAUSE=5s
COMPRESSOR_IMAGINARY_TIMEOUT=30s

# DATABASE: [mem, mongo, badger]
APP_DATABASE=mongo
DATABASE_MONGO_HOST=localhost
DATABASE_MONGO_PORT=27017
DATABASE_MONGO_RETRY_TIMES=4
DATABASE_MONGO_RETRY_PAUSE=5s
DATABASE_MONGO_TIMEOUT=30s
DATABASE_MONGO_LRU=100
DATABASE_BADGER_IN_MEMORY=false
DATABASE_BADGER_GC_RATIO=0.7
DATABASE_BADGER_CLEANUP_INTERVAL=5m
DATABASE_BADGER_LRU=100

# STORAGE: [mock, minio]
APP_STORAGE=minio
STORAGE_MINIO_HOST=localhost
STORAGE_MINIO_PORT=9000
STORAGE_MINIO_ACCESS_KEY=12345678
STORAGE_MINIO_SECRET_KEY=qwertyui
STORAGE_MINIO_TOKEN=
STORAGE_MINIO_SECURE=false
STORAGE_MINIO_RETRY_TIMES=4
STORAGE_MINIO_RETRY_PAUSE=5s
STORAGE_MINIO_TIMEOUT=30s
STORAGE_MINIO_LOCATION=eu-central-1
STORAGE_MINIO_PREFIX=
Loading
Loading