Skip to content

Commit 443bb45

Browse files
authored
Use devcontainer (#21)
* Add development container configuration and update Dockerfile for permissions * Add Python and sqlfluff for SQL linting in development container * Update super-linter configuration to use latest version and exclude specific files from validation * Add RunOnSave extension and configure SQLFluff auto-fix on save * Update super-linter workflow to trigger on pushes to the main branch
1 parent 099260b commit 443bb45

File tree

6 files changed

+56
-12
lines changed

6 files changed

+56
-12
lines changed

.devcontainer/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM alpine:latest
2+
3+
# Install common tools
4+
RUN apk add --no-cache bash git \
5+
mariadb mariadb-client \
6+
python3 py3-pip
7+
8+
# Install sqlfluff for SQL linting
9+
RUN ["/bin/bash", "-c", "pip3 --disable-pip-version-check --no-cache-dir install sqlfluff --break-system-packages"]
10+
11+
# Setup default user
12+
ARG USERNAME=vscode
13+
ARG USER_UID=1000
14+
ARG USER_GID=$USER_UID
15+
16+
RUN addgroup -g $USER_GID -S $USERNAME && \
17+
adduser -u $USER_UID -S -G $USERNAME -s /bin/bash $USERNAME
18+
19+
# Switch to the default user
20+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "Smart Cooking Database Development Container",
3+
"dockerFile": "Dockerfile",
4+
"customizations": {
5+
"settings": {
6+
"terminal.integrated.shell.linux": "/bin/bash"
7+
},
8+
"vscode": {
9+
"extensions": [
10+
"mtxr.sqltools-driver-mysql",
11+
"dorzey.vscode-sqlfluff",
12+
"emeraldwalk.RunOnSave"
13+
]
14+
}
15+
},
16+
"postStartCommand": "sqlfluff fix",
17+
"remoteUser": "vscode"
18+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
* text=auto
12
*.sql linguist-language=sql
23
*.sql linguist-detectable=true

.github/workflows/super-linter.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
name: Lint
33

44
on:
5-
push: null
5+
push:
6+
branches:
7+
- main
68
pull_request: null
79

810
permissions: {}
@@ -15,22 +17,19 @@ jobs:
1517
permissions:
1618
contents: read
1719
packages: read
18-
# To report GitHub Actions status checks
1920
statuses: write
2021

2122
steps:
2223
- name: Checkout code
2324
uses: actions/checkout@v4
2425
with:
25-
# super-linter needs the full git history to get the
26-
# list of files that changed across commits
2726
fetch-depth: 0
2827

2928
- name: Super-linter
30-
uses: super-linter/super-linter@v7.2.1
29+
uses: super-linter/super-linter@v7
3130
env:
32-
# To report GitHub Actions status checks
3331
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3432
VALIDATE_ALL_CODEBASE: false
3533
VALIDATE_JSON_PRETTIER: false
3634
SQLFLUFF_CONFIG_FILE: .sqlfluff
35+
FILTER_REGEX_EXCLUDE: "(.devcontainer/Dockerfile|.github/pull_request_template.md|.github/ISSUE_TEMPLATE/*.md)"

.vscode/settings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,13 @@
77
"editor.formatOnSave": true,
88
"files.insertFinalNewline": true,
99
"files.trimFinalNewlines": true,
10-
"files.trimTrailingWhitespace": true
10+
"files.trimTrailingWhitespace": true,
11+
"emeraldwalk.runonsave": {
12+
"commands": [
13+
{
14+
"match": "*.sql",
15+
"cmd": "sqlfluff fix '${fileBasename}'"
16+
}
17+
]
18+
}
1119
}

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ RUN find "${TEMP_SQL_DIR:?}/" -type f -name "*.sql" | while read -r file; do \
2020
done && \
2121
rm -rf "${TEMP_SQL_DIR:?}/"
2222

23-
# Set ownership
24-
RUN chown -R dbuser:dbuser /docker-entrypoint-initdb.d
25-
26-
# Adjust permissions on the MySQL data directory
27-
RUN chown -R dbuser:dbuser /var/lib/mysql /etc/mysql
23+
# Set ownership and adjust permissions on the MySQL data directory
24+
RUN chown -R dbuser:dbuser /docker-entrypoint-initdb.d && \
25+
chown -R dbuser:dbuser /var/lib/mysql /etc/mysql
2826

2927
# Expose the default MariaDB port (3306)
3028
EXPOSE 3306

0 commit comments

Comments
 (0)