Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #28 from TouristGuideApp/v3_integration
Browse files Browse the repository at this point in the history
V3 integration
  • Loading branch information
ErminaTrontzou authored Nov 26, 2022
2 parents f66d4c8 + 6b42cfa commit cf68508
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 103 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM gradle:jdk17 as build

WORKDIR /tourguide-back

COPY build.gradle ./
COPY settings.gradle ./
COPY src/ src/

RUN mv src/main/resources/application.properties this_doesnt_work_if_were_overwriting_the_file_were_reading_apparently && \
sed 's/spring.datasource.url.*/spring.datasource.url=jdbc:mysql:\/\/tourguide-db:3306\/tourguide/' this_doesnt_work_if_were_overwriting_the_file_were_reading_apparently |\
sed 's/spring.datasource.username.*/spring.datasource.username=ermina/' |\
sed 's/spring.datasource.password.*/spring.datasource.password=hypers/'\
> src/main/resources/application.properties &&\
rm this_doesnt_work_if_were_overwriting_the_file_were_reading_apparently

RUN gradle bootJar



FROM openjdk:17-slim

WORKDIR /tourguide-back

COPY --from=build /tourguide-back/build/libs/tourguide-*.jar ./

CMD ["sh", "-c", "java -jar tourguide-*.jar"]

8 changes: 8 additions & 0 deletions db-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mariadb:10

ENV MYSQL_ROOT_PASSWORD=rootpass
ENV MYSQL_DATABASE=tourguide
ENV MYSQL_USER=ermina
ENV MYSQL_PASSWORD=hypers

COPY tourguide.sql /docker-entrypoint-initdb.d/
249 changes: 249 additions & 0 deletions db-docker/tourguide.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Εξυπηρετητής: 127.0.0.1
-- Χρόνος δημιουργίας: 27 Οκτ 2022 στις 21:13:33
-- Έκδοση διακομιστή: 10.4.22-MariaDB
-- Έκδοση PHP: 8.1.2

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Βάση δεδομένων: `tourguide`
--

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `images`
--

CREATE TABLE `images` (
`id` int(11) NOT NULL,
`file_name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`latitude` varchar(255) NOT NULL,
`longitude` varchar(255) NOT NULL,
`views` int(11) NOT NULL,
`owner_name` varchar(255) NOT NULL,
`date_taken` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Άδειασμα δεδομένων του πίνακα `images`
--

INSERT INTO `images` (`id`, `file_name`, `description`, `title`, `latitude`, `longitude`, `views`, `owner_name`, `date_taken`) VALUES
(1, 'lalala', 'okeydesc', 'This is the title', '-098765', '-098765', 0, 'Your mum', '2022-10-20 18:09:16'),
(2, 'ok', 'lalala', 'this is the title', '87654', '87654', 13, 'your mother', '2022-10-20 18:09:54'),
(3, 'https://live.staticflickr.com/65535/48685085288_db0141fdfd_o.jpg', 'The White Tower of Thessaloniki (Ladino: Kuli Blanka, Greek: Λευκός Πύργος Lefkos Pyrgos, Turkish: Beyaz Kule), is a monument and museum on the waterfront of the city of Thessaloniki, capital of the region of Macedonia in northern Greece. The present towe', 'White Tower Thessaloniki', '40.626580', '22.947538', 282, 'txikita69', '2015-08-17 17:19:09');

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `image_tags`
--

CREATE TABLE `image_tags` (
`id` int(11) NOT NULL,
`image_id` int(11) NOT NULL,
`tag_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Άδειασμα δεδομένων του πίνακα `image_tags`
--

INSERT INTO `image_tags` (`id`, `image_id`, `tag_id`) VALUES
(2, 1, 1),
(1, 1, 3),
(3, 2, 2),
(4, 3, 2);

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `tags`
--

CREATE TABLE `tags` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Άδειασμα δεδομένων του πίνακα `tags`
--

INSERT INTO `tags` (`id`, `name`) VALUES
(1, 'cool'),
(2, 'ok'),
(3, 'aaaa');

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `users`
--

CREATE TABLE `users` (
`id` int(11) NOT NULL,
`first_name` varchar(255) NOT NULL,
`last_name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`is_admin` tinyint(1) NOT NULL,
`is_disabled` tinyint(1) NOT NULL,
`disabled` bit(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `user_collections`
--

CREATE TABLE `user_collections` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`is_public` tinyint(1) NOT NULL,
`user_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Δομή πίνακα για τον πίνακα `user_collections_images`
--

CREATE TABLE `user_collections_images` (
`id` int(11) NOT NULL,
`image_id` int(11) NOT NULL,
`user_collection_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Ευρετήρια για άχρηστους πίνακες
--

--
-- Ευρετήρια για πίνακα `images`
--
ALTER TABLE `images`
ADD PRIMARY KEY (`id`);

--
-- Ευρετήρια για πίνακα `image_tags`
--
ALTER TABLE `image_tags`
ADD PRIMARY KEY (`id`),
ADD KEY `image_id` (`image_id`,`tag_id`),
ADD KEY `tag_id` (`tag_id`);

--
-- Ευρετήρια για πίνακα `tags`
--
ALTER TABLE `tags`
ADD PRIMARY KEY (`id`);

--
-- Ευρετήρια για πίνακα `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);

--
-- Ευρετήρια για πίνακα `user_collections`
--
ALTER TABLE `user_collections`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`);

--
-- Ευρετήρια για πίνακα `user_collections_images`
--
ALTER TABLE `user_collections_images`
ADD PRIMARY KEY (`id`),
ADD KEY `image_id` (`image_id`,`user_collection_id`),
ADD KEY `user_collection_id` (`user_collection_id`);

--
-- AUTO_INCREMENT για άχρηστους πίνακες
--

--
-- AUTO_INCREMENT για πίνακα `images`
--
ALTER TABLE `images`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT για πίνακα `image_tags`
--
ALTER TABLE `image_tags`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT για πίνακα `tags`
--
ALTER TABLE `tags`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT για πίνακα `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT για πίνακα `user_collections`
--
ALTER TABLE `user_collections`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT για πίνακα `user_collections_images`
--
ALTER TABLE `user_collections_images`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Περιορισμοί για άχρηστους πίνακες
--

--
-- Περιορισμοί για πίνακα `image_tags`
--
ALTER TABLE `image_tags`
ADD CONSTRAINT `image_tags_ibfk_1` FOREIGN KEY (`image_id`) REFERENCES `images` (`id`),
ADD CONSTRAINT `image_tags_ibfk_2` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`);

--
-- Περιορισμοί για πίνακα `user_collections`
--
ALTER TABLE `user_collections`
ADD CONSTRAINT `user_collections_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);

--
-- Περιορισμοί για πίνακα `user_collections_images`
--
ALTER TABLE `user_collections_images`
ADD CONSTRAINT `user_collections_images_ibfk_1` FOREIGN KEY (`user_collection_id`) REFERENCES `user_collections` (`id`),
ADD CONSTRAINT `user_collections_images_ibfk_2` FOREIGN KEY (`image_id`) REFERENCES `images` (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
41 changes: 41 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
tourguide-db:
image: tourguide-db
build: db-docker
volumes:
- tourguide-db-vol:/var/lib/mysql
restart: unless-stopped

# tourguide-phpmyadmin:
# image: phpmyadmin:latest
# ports:
# - 80:80
# environment:
# - PMA_HOST=tourguide-db
# - PMA_PORT=3306
# - PMA_USER=ermina
# - PMA_PASSWORD=hypers
# depends_on:
# - tourguide-db
# restart: unless-stopped

tourguide-back:
image: tourguide-back
build: ./
ports:
- 8080:8080
depends_on:
- tourguide-db
restart: unless-stopped

# tourguide-front:
# image: tourguide-front
# build: ../Tourist-Guide-Frontend-App
# ports:
# - 80:3000
# depends_on:
# - tourguide-back
# restart: unless-stopped

volumes:
tourguide-db-vol:
3 changes: 3 additions & 0 deletions docker-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo docker-compose logs -f
3 changes: 3 additions & 0 deletions docker-set-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo docker-compose up -d --remove-orphans --build
3 changes: 3 additions & 0 deletions docker-stop-and-clear.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo docker-compose down -v
3 changes: 3 additions & 0 deletions docker-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sudo docker-compose down
Loading

0 comments on commit cf68508

Please sign in to comment.