Sapper × Go (echo) × Docker development environment construction

Introduction

Front: Svelte.js (Sapper), API: Go (echo) I wanted to make an app Built using Docker.

How far to do

To the point where Sapper and echo can be connected on the local host

Initial directory structure

In building this environment, Create with "Vue.js + Go language + Docker"! Image upload function implementation Hands-on was used as a reference.

Simple and easy to understand.


.
├── docker-compose.yml
└── server

Sapper development environment construction


npx degit "sveltejs/sapper-template#rollup" client

cd client
npm install
touch Dockerfile_develop

Although it is a Dockerfile, I want to prepare a Dockerfile for production in my case, so I name it Dockerfile_develop. If you don't need to divide it, or if it seems to fit in a multi-stage build, you can use one.

Dockerfile

FROM mhart/alpine-node:12

WORKDIR /app
COPY package.json package-lock.json ./

RUN npm ci

ENV HOST=0.0.0.0
EXPOSE 3000

docker-compose.yml

version: '3.8'

services:
  client:
    env_file: .env
    build: 
      context: ./client
      dockerfile: Dockerfile_${DOCKER_ENV} #Delete this line if you don't need it
    ports:
      - 3000:3000
    tty: true
    volumes:
      - ./client:/app
    command: npm run dev
touch .env
vim .env
DOCKER_ENV=develop

Let's see if Sapper starts at this stage

docker-compose up --build

Go (echo) development environment construction

cd server
touch Dockerfile
touch main.go

Dockerfile

FROM golang:1.15.2-alpine


WORKDIR /go/src/api
ADD .  /go/src/api
ENV GO111MODULE=off

RUN apk update && apk add curl git

main.go

package main

import (
  "net/http"
  "github.com/labstack/echo"
)

func main() {
  e := echo.New()
  e.GET("/", func(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World")
  })
  e.Logger.Fatal(e.Start(":8080"))
}

docker-compose.yml


version: '3.8'
...
  server:
    build: ./server
    ports:
      - 8080:8080
    tty: true
    volumes:
      - ./server:/api

Launch echo's local server.

docker-compose up --build
docker-compose exec server /bin/ash
go get github.com/labstack/echo
go run main.go

If you can access localhost: 8080, you're done.

in conclusion

Next, I want to go to the point where I put Gorm, MySQL

Reference material

Make with "Vue.js + Go language + Docker"! Image upload function implementation hands-on How to create a development environment for svelte Hello World Recipe

Recommended Posts

Sapper × Go (echo) × Docker development environment construction
Docker environment construction
Laravel development environment construction with Docker (Mac)
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Rails Docker environment construction
java development environment construction
A reminder of Docker and development environment construction
Wordpress local environment construction & development procedure with Docker
Rails6 development environment construction [Mac]
WSL2 + VSCode + Docker development environment
BEAR application Docker development environment construction example (docker-sync, Mutagen)
MySQL 5.7 (Docker) environment construction memo
Redmine (Docker) environment construction memo
[Docker] Rails 5.2 environment construction with docker
Docker × Spring Boot environment construction
[Docker] postgres, pgadmin4 environment construction
React environment construction with Docker
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Node.js environment construction with Docker Compose
Environment construction for Servlet application development
Environment construction with Docker for beginners
Laravel + Docker Laradock usage environment construction
[Unity] Android development environment construction procedure
Rails on Docker environment construction procedure
[Environment construction with Docker] Rails 6 & MySQL 8
Build Unity development environment on docker
Build Go development environment with WSL2 + Docker Desktop + VSCode (Remote --Containers)
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
PostgreSQL environment construction with Docker (from setup to just before development)
SQL statement learning ~ Environment construction ~ Docker + MySQL
CentOS8 + Anaconda + Django development environment construction procedure
GPU environment construction with Docker [October 2020 version]
[Processing x Java] Construction of development environment
Rails environment construction with Docker (personal apocalypse)
Build a PureScript development environment with Docker
Universal Robotics UR Caps development environment construction
Java development environment construction memo on Mac
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Create Spring Boot-gradle-mysql development environment with Docker
Laravel + MySQL + phpMyadmin environment construction with Docker
Build a Wordpress development environment with Docker
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker
Build a simple Docker + Django development environment
Spring Boot environment construction with Docker (January 2021 version)
Build a development environment for Docker + Rails6 + Postgresql
Docker + DynamoDB local + C ++ environment construction and practice
[Jakarta EE 8 application development with Gradle] 1. Environment construction
[Java] Environment construction
Environment construction command memo with Docker on AWS
Build a WordPress development environment quickly with Docker
Kaggle environment construction using official Docker and vscode
Rails6 [API mode] + MySQL5.7 environment construction with Docker
Improve the performance of your Docker development environment
Java environment construction
Java development environment
Development environment construction using IntelliJ IDEA + Maven + Tomcat 9
Build a simple Docker Compose + Django development environment
IntelliJ + Docker (APP + DB) + SpringBoot (Maven) environment construction
Ruby on Rails development environment construction on M1 Mac