Skip to content

Commit c3343ec

Browse files
authored
Merge pull request #1 from teamdigitale/devcontainer
chore: devcontainer setup
2 parents 872cc29 + 321edad commit c3343ec

File tree

5 files changed

+99
-1
lines changed

5 files changed

+99
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM oven/bun:debian
2+
3+
# Config Bun
4+
ENV PATH="~/.bun/bin:${PATH}"
5+
RUN ln -s /usr/local/bin/bun /usr/local/bin/node
6+
7+
# Update packages
8+
RUN if [ "alpine" == "alpine" ] ; then apk update ; else apt-get update ; fi
9+
10+
# Install Git
11+
RUN if [ "alpine" == "alpine" ] ; then apk add git ; else apt-get install -y git ; fi
12+

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/marcosgomesneto/bun-devcontainers/tree/main/src/bun-postgresql
3+
{
4+
"name": "Dataviz-Srv",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
// Configure tool-specific properties.
9+
"customizations": {
10+
// Configure properties specific to VS Code.
11+
"vscode": {
12+
// Add the IDs of extensions you want installed when the container is created.
13+
"extensions": [
14+
"oven.bun-vscode",
15+
"cweijan.vscode-postgresql-client2",
16+
"esbenp.prettier-vscode",
17+
"ms-azuretools.vscode-docker",
18+
"Prisma.prisma"
19+
],
20+
"settings": {
21+
"editor.formatOnSave": true,
22+
"editor.codeActionsOnSave": {
23+
"source.fixAll": true,
24+
"source.fixAll.eslint": true,
25+
"source.organizeImports": true,
26+
"addMissingImports": true
27+
},
28+
"editor.defaultFormatter": "esbenp.prettier-vscode",
29+
"[prisma]": {
30+
"editor.defaultFormatter": "Prisma.prisma"
31+
}
32+
}
33+
}
34+
},
35+
"postCreateCommand": "sh .devcontainer/postCreateCommand.sh"
36+
}

.devcontainer/docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
container_name: dataviz-srv
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
10+
volumes:
11+
- ../..:/workspaces:cached
12+
- dataviz-srv_node_modules:/workspaces/dataviz-srv/node_modules
13+
14+
# Overrides default command so things don't shut down after the process ends.
15+
command: sleep infinity
16+
17+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
18+
network_mode: service:db
19+
20+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
21+
# (Adding the "ports" property to this file will not forward from a Codespace.)
22+
23+
db:
24+
container_name: dataviz-db
25+
image: postgres:latest
26+
restart: unless-stopped
27+
volumes:
28+
- dataviz-postgres-data:/var/lib/postgresql/data
29+
environment:
30+
POSTGRES_PASSWORD: postgres
31+
POSTGRES_USER: postgres
32+
POSTGRES_DB: postgres
33+
34+
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
35+
# (Adding the "ports" property to this file will not forward from a Codespace.)
36+
37+
volumes:
38+
dataviz-postgres-data:
39+
dataviz-srv_node_modules:

.devcontainer/postCreateCommand.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
echo "Create .env file"
2+
3+
if [ ! -e .env ]; then
4+
echo "DATABASE_URL=postgres://[email protected]:5432/postgres" > .env
5+
fi
6+
7+
echo "Set permissions"
8+
chown -R node:node node_modules
9+
10+
echo "Installing Deps"
11+
bun i

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# serverino
1+
# Dataviz chart server
22

33
To install dependencies:
44

0 commit comments

Comments
 (0)