Skip to content

Commit 378ca8e

Browse files
init: github codespaces (#1666)
1 parent ebe45b8 commit 378ca8e

File tree

8 files changed

+107
-1
lines changed

8 files changed

+107
-1
lines changed

.devcontainer/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/java/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Java version: 16
4+
ARG VARIANT="16"
5+
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
6+
7+
# [Option] Install Maven
8+
ARG INSTALL_MAVEN="true"
9+
ARG MAVEN_VERSION="3.8.3"
10+
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi
11+
12+
# [Optional] Uncomment this section to install additional OS packages.
13+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
14+
# && apt-get -y install --no-install-recommends <your-package-list-here>

.devcontainer/devcontainer.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/java
3+
{
4+
"name": "Java",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/fp-abakus",
8+
9+
// Set *default* container specific settings.json values on container create.
10+
"settings": {
11+
"java.home": "/docker-java-home",
12+
"maven.settingsFile": "/workspace/.github/.m2/settings.xml",
13+
"sqltools.connections": [
14+
{
15+
"name": "Container database",
16+
"driver": "PostgreSQL",
17+
"previewLimit": 50,
18+
"server": "localhost",
19+
"port": 5432,
20+
"database": "fpabakus_unit",
21+
"username": "fpabakus_unit",
22+
"password": "fpabakus_unit"
23+
}
24+
],
25+
"files.eol": "\n",
26+
"files.insertFinalNewline": true,
27+
"files.trimFinalNewlines": true,
28+
"files.trimTrailingWhitespace": true,
29+
"editor.formatOnSave": true,
30+
"editor.codeActionsOnSave": {
31+
"source.organizeImports": true
32+
}
33+
},
34+
35+
// Add the IDs of extensions you want installed when the container is created.
36+
"extensions": [
37+
"vscjava.vscode-java-pack",
38+
"ms-azuretools.vscode-docker",
39+
"mtxr.sqltools",
40+
"mtxr.sqltools-driver-pg",
41+
"eamodio.gitlens"
42+
],
43+
44+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
45+
"forwardPorts": [3000, 5432],
46+
47+
"postAttachCommand": "sh .devcontainer/postAttachCommand.sh",
48+
49+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
50+
"remoteUser": "vscode"
51+
}

.devcontainer/docker-compose.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: "3"
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
args:
9+
- USER_UID=1000
10+
- USER_GID=1000
11+
12+
volumes:
13+
- ..:/workspace:cached
14+
15+
# Overrides default command so things don't shut down after the process ends.
16+
command: sleep infinity
17+
18+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
19+
network_mode: service:db
20+
21+
db:
22+
image: postgres:latest
23+
restart: unless-stopped
24+
volumes:
25+
- postgres_data:/var/lib/postgresql/data
26+
- /workspace/.devcontainer/db:/docker-entrypoint-initdb.d
27+
environment:
28+
TZ: "UTC"
29+
PGTZ: "UTC"
30+
POSTGRES_PASSWORD: "fpabakus_unit"
31+
POSTGRES_USER: "fpabakus_unit"
32+
POSTGRES_DB: fpabakus_unit
33+
34+
# Persist database information after your VM shuts down (just these two lines!)
35+
volumes:
36+
postgres_data:

.devcontainer/postAttachCommand.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mkdir -p ~/.m2
2+
cp /workspace/.github/.m2/settings.xml ~/.m2/

.github/.m2/settings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<server>
3737
<id>github</id>
3838
<username>x-access-token</username>
39-
<password>${env.GITHUB_TOKEN}</password>
39+
<password>${env.GH_ACCESS_TOKEN}</password>
4040
</server>
4141
</servers>
4242
</settings>

.github/workflows/build-pr.yml

+1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ jobs:
4444
mvn verify --batch-mode -DtrimStackTrace=false --settings .github/.m2/settings.xml
4545
env:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
4748
DATASOURCE_HOST: localhost
4849
DATASOURCE_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
env:
5757
TZ: "Europe/Oslo"
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
5960
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6061
DATASOURCE_HOST: localhost
6162
DATASOURCE_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port

.github/workflows/release-kontrakt.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ jobs:
2222
mvn deploy -e --batch-mode --settings .github/.m2/settings.xml --file pom.xml -am -pl kontrakt -DtrimStackTrace=false -Dchangelist= -Dsha1= -Drevision=$NEW_VERSION -Dfile.encoding=UTF-8 -DdeployAtEnd=true
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
25+
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
2526
NEW_VERSION: ${{ github.event.release.tag_name }}

0 commit comments

Comments
 (0)