DEV Community

Mustafa ERBAY
Mustafa ERBAY

Posted on • Originally published at mustafaerbay.com.tr

Securely Deploying an SQLite Database to a Docker Container with

Guide to Securely Deploying an SQLite Database to a Docker Container with GitHub Actions

I remember my VPS disk filling up to 100% on April 28th, but in this post, I'm sharing a guide on securely deploying an SQLite database to a Docker container using GitHub Actions.

Security Definition

Before deploying the database, we must define security. We will do this definition in the Dockerfile and the YAML file we will use to deploy to the container.

# Dockerfile
FROM python:3.9-slim

# SQLite installation
RUN apt-get update && apt-get install -y sqlite3

# SQLite database creation
RUN sqlite3 /db.sqlite3 < /schema.sql

# Our database file to be deployed to the container
COPY database.db /db.sqlite3
Enter fullscreen mode Exit fullscreen mode

GitHub Actions Guide

Let's create the YAML file that enables us to deploy to the container using GitHub Actions.

# .github/workflows/deploy.yml
name: Deploy SQLite Database

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup
        run: |
          python -m pip install --upgrade pip
          pip install docker

      - name: Build Docker image
        run: docker build -t my-sqlite-app .

      - name: Deploy Docker image
        run: docker push my-sqlite-app
Enter fullscreen mode Exit fullscreen mode

Security Checks

Before deploying, we will perform security checks to ensure a secure deployment to the container.

# Security checks
docker run --rm -t my-sqlite-app bash -c "sqlite3 /db.sqlite3 '.schema' | grep -q 'CREATE TABLE'"
Enter fullscreen mode Exit fullscreen mode

Conclusion

It is possible to securely deploy an SQLite database to a Docker container using GitHub Actions. In this guide, we shared the security definition, using GitHub Actions, security checks, and the results.

Do you also risk encountering a similar problem? In the continuation of this article, we must define security before deploying to the container.

💡 Tip

Define security before deploying to a container using GitHub Actions.

ℹ️ Information

Create the YAML file you will use to deploy to the container using GitHub Actions.

🔥 Caution

Perform security checks before deploying to a container using GitHub Actions.


In this guide, we shared how to securely deploy an SQLite database to a Docker container using GitHub Actions. Do you also risk encountering a similar problem?

Top comments (0)