snippetbox

module
v0.0.0-...-7e02a57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: MIT

README

Snippetbox from Let' Go

Developing snippetbox example application following along "Let's Go" book from Alex Edwards

Generate TLS certificate

To generate the certificate to use for development, run the following command inside TLS folder:

go run /usr/lib/go/src/crypto/tls/generate_cert.go --rsa-bits=2048 --host=localhost

Run the application

Since we are going to run the database in a container, we need to create a network for the application and the database to communicate.

dk network create snippetbox

Run the database in a container with the following command:

dk run --rm -d \
    --name snippetbox-mysql \
    -e MYSQL_ROOT_PASSWORD=secret \
    -e MYSQL_DATABASE=snippetbox \
    -p 3306:3306 \
    --user 1000:1000 \
    --network snippetbox \
    -v $PWD/db-init.sql:/docker-entrypoint-initdb.d/db-init.sql \
    -v $PWD/data:/var/lib/mysql \
    mysql:8.3

Then we can run the application with the following command:

dk run -it --rm \
    --network snippetbox \
    -w $PWD -v $PWD:$PWD \
    -p 4000:4000 \
    docker.io/cosmtrek/air air

Directories

Path Synopsis
cmd
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL