diff --git a/Dockerfile-dev b/Dockerfile-dev new file mode 100644 index 00000000..07b4a801 --- /dev/null +++ b/Dockerfile-dev @@ -0,0 +1,20 @@ +# Copyright 2023 The Archivista Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM golang:1.21.5-alpine@sha256:5c1cabd9a3c6851a3e18735a2c133fbd8f67fe37eb3203318b7af2ffd2547095 AS build +WORKDIR /src +RUN apk update && apk add --no-cache file git +ENV GOMODCACHE /root/.cache/gocache +RUN go install github.com/githubnemo/CompileDaemon@latest +ENTRYPOINT CompileDaemon -log-prefix=false -build="go build -o /out/archivista ./cmd/archivista" -command="/out/archivista" diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..3262184c --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +# Copyright 2023 The Archivista Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Nothing to be run by default as the CodeQL autobuild tries to run make +# See https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#autobuild-for-go +all: help + +run-dev: ## Run the dev server + @echo "Running dev server. It will refresh automatically when you change code." + @docker build -t archivista:dev . + @docker compose -f compose-dev.yml up --remove-orphans + + +.PHONY: stop +stop: ## Stop the dev server + @docker-compose down -v + + +.PHONY: clean +clean: + $(MAKE) stop + @docker compose rm --force + @docker rmi archivista-archivista --force + + +.PHONY: test +test: ## Clean up the dev server + @bash ./test/test.sh + +help: ## Show this help + @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' \ No newline at end of file diff --git a/compose-dev.yml b/compose-dev.yml new file mode 100644 index 00000000..b334309b --- /dev/null +++ b/compose-dev.yml @@ -0,0 +1,80 @@ +# Copyright 2023 The Archivista Contributors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +version: '3.9' + +services: + db: + image: mysql:oracle + command: --default-authentication-plugin=mysql_native_password + restart: always + ports: + - 3306:3306 + environment: + MYSQL_DATABASE: testify + MYSQL_ROOT_PASSWORD: example + volumes: + - mysqldata:/var/lib/mysql + + archivista: + build: + context: . + dockerfile: ./Dockerfile-dev + restart: unless-stopped + environment: + ARCHIVISTA_LISTEN_ON: tcp://0.0.0.0:8082 + ARCHIVISTA_ENABLE_SPIFFE: "false" + ARCHIVISTA_STORAGE_BACKEND: BLOB + ARCHIVISTA_FILE_DIR: /tmp/archivista/ + ARCHIVISTA_FILE_SERVE_ON: :8081 + ARCHIVISTA_BLOB_STORE_USE_TLS: "false" + ARCHIVISTA_BLOB_STORE_ACCESS_KEY_ID: testifytestifytestify + ARCHIVISTA_BLOB_STORE_SECRET_ACCESS_KEY_ID: exampleexampleexample + ARCHIVISTA_BLOB_STORE_BUCKET_NAME: attestations + ARCHIVISTA_BLOB_STORE_ENDPOINT: minio:9000 + ARCHIVISTA_ENABLE_GRAPHQL: "true" + ARCHIVISTA_GRAPHQL_WEB_CLIENT_ENABLE: "true" + ARCHIVISTA_CORS_ALLOW_ORIGINS: "http://localhost:1234" + + ports: + - 8081:8081 + - 8082:8082 + volumes: + - fileserver:/tmp/archivista + - ./:/src + + minio: + image: quay.io/minio/minio + restart: always + command: server /data --console-address ":9001" + ports: + - 9000:9000 + - 9001:9001 + environment: + MINIO_ROOT_USER: testifytestifytestify + MINIO_ROOT_PASSWORD: exampleexampleexample + volumes: + - miniodata:/data + + minio-init: + image: quay.io/minio/mc + restart: on-failure + command: mb --insecure --ignore-existing testminio/attestations + environment: + MC_HOST_testminio: http://testifytestifytestify:exampleexampleexample@minio:9000 + +volumes: + fileserver: + miniodata: + mysqldata: