Skip to content

Commit

Permalink
Add Visual Studio Code Dev Container (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutaro-sakamoto authored Nov 3, 2024
1 parent 214f43c commit 4fb280c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM almalinux:9

SHELL ["/bin/bash", "-c"]

# classpath settings
ENV CLASSPATH :/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar
RUN echo 'export CLASSPATH=:/usr/lib/opensourcecobol4j/libcobj.jar:/usr/lib/Open-COBOL-ESQL-4j/postgresql.jar:/usr/lib/Open-COBOL-ESQL-4j/ocesql4j.jar' >> ~/.bashrc

# install dependencies
RUN dnf update -y
RUN dnf install -y epel-release
RUN dnf install -y gcc make bison flex automake autoconf diffutils gettext java-21-openjdk-devel git-clang-format cppcheck libtool gettext-devel

# install sbt
RUN curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && echo Y | ./cs setup
27 changes: 27 additions & 0 deletions .devcontainer/boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Install opensource COBOL 4J
cd opensourcecobol4j/
./configure --prefix=/usr/
make
make install
cd ../

# Install Open COBOL ESQL 4J
cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib/
cp /usr/lib/opensourcecobol4j/libcobj.jar dblibj/lib/
mkdir -p /usr/lib/Open-COBOL-ESQL-4j
curl -L -o /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.24.jar
cp /usr/lib/Open-COBOL-ESQL-4j/postgresql.jar dblibj/lib/
./configure --prefix=/usr/
make
make install

# Set up git config
git config --global --add safe.directory /workspaces/Open-COBOL-ESQL-4j

# Set up pre-commit hook
cp .devcontainer/term_settings/pre-commit .git/hooks/pre-commit

# Set up ~/.bashrc
cat .devcontainer/term_settings/extra_bashrc.sh >> ~/.bashrc
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Open COBOL ESQL 4J development",
"dockerComposeFile": "docker-compose.yml",
"service": "oc4j_client",
"workspaceFolder": "/workspaces/Open-COBOL-ESQL-4j",
"postCreateCommand": ".devcontainer/boot.sh"
}
28 changes: 28 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'

services:
oc4j_db:
image: postgres:13
container_name: oc4j_db
environment:
- POSTGRES_USER=main_user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=testdb
ports:
- "5432:5432"

oc4j_client:
image: oc4j_client
container_name: oc4j_client
build:
context: .
dockerfile: Dockerfile
stdin_open: true
volumes:
- ../..:/workspaces:cached
tty: true
depends_on:
oc4j_db:
condition: service_started
logging:
driver: none
11 changes: 11 additions & 0 deletions .devcontainer/term_settings/extra_bashrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
alias ls='ls --color=auto'
alias ll='ls -l'
alias la='ls -a'

alias g='git'

parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\e[0;32m[\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\e[0;32m]\033[00m "
4 changes: 4 additions & 0 deletions .devcontainer/term_settings/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

./format
git add -u

0 comments on commit 4fb280c

Please sign in to comment.