From 2065e06e4d702b43d62c5ad10a7dc92c1af0fc24 Mon Sep 17 00:00:00 2001 From: LogolicusZ Date: Fri, 5 Apr 2024 11:39:54 +0200 Subject: [PATCH] Changes: - Added Justfile and added Build - Added init.sql, docker compose and Dockerfile from other Repo - Created Docker-compose.build file - updated Css --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ Justfile | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.build.yml | 9 +++++++++ docker-compose.yml | 30 ++++++++++++++++++++++++++++++ init.sql | 7 +++++++ src/app.scss | 6 +++--- 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 Dockerfile create mode 100644 Justfile create mode 100644 docker-compose.build.yml create mode 100644 docker-compose.yml create mode 100644 init.sql diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c2f3f0a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Builder-Stage +FROM node:20-alpine AS builder + +# Setzt das Arbeitsverzeichnis im Container +WORKDIR /git + +# Kopiert den Repository-Inhalt in den Container +COPY . . + +# Installiert Abhängigkeiten und baut die Site. Ausgabeverzeichnis ist /app/build +RUN yarn install && yarn run build + +# Endstufe +FROM caddy:2-alpine + +# Setzt das Arbeitsverzeichnis im Container +WORKDIR /app + +# Kopiert das Build-Verzeichnis aus der Builder-Stage nach /web +COPY --from=builder /git/build /app + +# Caddyfile-Konfiguration, um Dateien aus /web zu bedienen +RUN echo -e ":80 {\n root * /web\n file_server\n}" > /etc/caddy/Caddyfile + +# Macht Port 80 frei +EXPOSE 80 + +# Startet Caddy mit der gegebenen Caddyfile +CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"] + +# Befreit das Build-Verzeichnis aus der Builder-Stage +ONBUILD RUN rm -rf /git \ No newline at end of file diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..1003902 --- /dev/null +++ b/Justfile @@ -0,0 +1,37 @@ +# Just configuration +set dotenv-load + +# Default variables +default_image := 'gitpot.dev/logolicusz/explorecraft_logolcicusz_knockoff:latest' +default_tag := 'latest' + +alias dewit := build + +# Run dev server by default +default: dev + +_install: + yarn install + +# Run vite dev server +dev: _install + @echo "Running vite development server..." + yarn run dev --open + +# Run vite preview server +preview: _install + @echo "Running vite preview server..." + yarn run build + yarn run preview --open + +# Publish container to Gitpot registry +publish image=default_image: + echo "$GITPOT_TOKEN" | docker login gitpot.dev -u $GITPOT_USERNAME --password-stdin + docker push {{image}} + @echo "Published {{image}} successfuly! Use 'docker pull {{image}}' to pull the container." + + +# build container image with specified runner (default runner: docker) +build tag=default_tag: + @echo "Running with 'docker' and tagging as '{{tag}}'..." + TAG="{{tag}}" docker compose -f docker-compose.build.yml build \ No newline at end of file diff --git a/docker-compose.build.yml b/docker-compose.build.yml new file mode 100644 index 0000000..d6cb328 --- /dev/null +++ b/docker-compose.build.yml @@ -0,0 +1,9 @@ +services: + web: + image: gitpot.dev/logolicusz/explorecraft_logolcicusz_knockoff:${TAG} + build: + context: . + dockerfile: Dockerfile + no_cache: true + ports: + - "3000:80" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6936d5d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,30 @@ +services: + db: + container_name: mariadb + image: mariadb:10.5.8 + volumes: + - picture_volume:/var/lib/mysql + - /Users/logolicusz/Git/m169-weekly/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql + environment: + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: picture_db + MYSQL_USER: user + MYSQL_PASSWORD: userpassword + command: --default-authentication-plugin=mysql_native_password + networks: + - internal-bridge + + web: + image: gitpot.dev/logolicusz/explorecraft_logolcicusz_knockoff:latest + ports: + - "3000:80" + networks: + - internal-bridge + +volumes: + picture_volume: + external: true + +networks: + internal-bridge: + driver: bridge diff --git a/init.sql b/init.sql new file mode 100644 index 0000000..72c4ecb --- /dev/null +++ b/init.sql @@ -0,0 +1,7 @@ +CREATE DATABASE IF NOT EXISTS picture_db; +USE picture_db; + +CREATE TABLE IF NOT EXISTS pictures ( + id INT AUTO_INCREMENT PRIMARY KEY, + url VARCHAR(255) NOT NULL +); diff --git a/src/app.scss b/src/app.scss index a79e5dc..f0dd366 100644 --- a/src/app.scss +++ b/src/app.scss @@ -17,7 +17,7 @@ h1, h2, h3, h4, h5, h6, body { --primary: #7B41F5; --primary-hover: #5d30bc; --primary-focus: rgba(99, 54, 197, 0.250); - --primary-inverse: #FFF; + --primary-inverse: #FEFCED; background-color: #FEFCED; } @@ -28,7 +28,7 @@ h1, h2, h3, h4, h5, h6, body { --primary: #C0FE1F; --primary-hover: #81ab15; --primary-focus: rgba(192, 254, 31,0.250); - --primary-inverse: #FFF; + --primary-inverse: #FEFCED; background-color: #191816; } } @@ -39,7 +39,7 @@ h1, h2, h3, h4, h5, h6, body { --primary: #C0FE1F; --primary-hover: #81ab15; --primary-focus: rgba(192, 254, 31,0.250); - --primary-inverse: #FFF; + --primary-inverse: #FEFCED; background-color: #191816; }