Merge pull request #437 from usbharu/devcontainer

Devcontainer
This commit is contained in:
usbharu 2024-06-21 18:27:23 +09:00 committed by GitHub
commit f8597dc540
5 changed files with 116 additions and 5 deletions

17
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM mcr.microsoft.com/devcontainers/java:1-21-bullseye
ARG INSTALL_MAVEN="false"
ARG MAVEN_VERSION=""
ARG INSTALL_GRADLE="true"
ARG GRADLE_VERSION=""
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

View File

@ -0,0 +1,30 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java-postgres
{
"name": "Java & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or with the host.
"forwardPorts": [
5432,
8080,
27017
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
// Configure tool-specific properties.
"customizations": {
"jetbrains": {
"backend": "IntelliJ"
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View File

@ -0,0 +1,56 @@
version: '3.8'
volumes:
postgres-data:
mongo-data:
services:
app:
container_name: javadev
build:
context: .
dockerfile: Dockerfile
environment:
# NOTE: POSTGRES_DB/USER/PASSWORD should match values in db container
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_HOSTNAME: postgresdb
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
db:
container_name: postgresdb
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
# NOTE: POSTGRES_DB/USER/PASSWORD should match values in app container
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: postgres
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
mongodb:
container_name: "mongodb"
hostname: mongodb
image: mongo
restart: unless-stopped
volumes:
- mongo-data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password

View File

@ -24,17 +24,17 @@ spring:
default-property-inclusion: always default-property-inclusion: always
datasource: datasource:
driver-class-name: org.postgresql.Driver driver-class-name: org.postgresql.Driver
url: "jdbc:postgresql:hideout3" url: "jdbc:postgresql:postgres"
username: "postgres" username: "postgres"
password: "" password: "postgres"
data: data:
mongodb: mongodb:
auto-index-creation: true auto-index-creation: true
host: localhost host: localhost
port: 27017 port: 27017
database: hideout database: hideout
# username: hideoutuser username: root
# password: hideoutpass password: password
servlet: servlet:
multipart: multipart:
max-file-size: 40MB max-file-size: 40MB

View File

@ -56,6 +56,8 @@ create table if not exists actors
move_to bigint null default null, move_to bigint null default null,
emojis varchar(3000) not null default '', emojis varchar(3000) not null default '',
deleted boolean not null default false, deleted boolean not null default false,
icon bigint null,
banner bigint null,
unique ("name", "domain"), unique ("name", "domain"),
constraint fk_actors_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict, constraint fk_actors_instance__id foreign key ("instance") references instance (id) on delete restrict on update restrict,
constraint fk_actors_actors__move_to foreign key ("move_to") references actors (id) on delete restrict on update restrict constraint fk_actors_actors__move_to foreign key ("move_to") references actors (id) on delete restrict on update restrict
@ -91,6 +93,12 @@ create table if not exists media
mime_type varchar(255) not null, mime_type varchar(255) not null,
description varchar(4000) null description varchar(4000) null
); );
alter table actors
add constraint fk_actors_media__icon foreign key ("icon") references media (id) on delete cascade on update cascade;
alter table actors
add constraint fk_actors_media__banner foreign key ("banner") references media (id) on delete cascade on update cascade;
create table if not exists posts create table if not exists posts
( (
id bigint primary key, id bigint primary key,