0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GoのDocker開発環境を作る

Last updated at Posted at 2023-04-06

Goで開発環境を作る時Dockerを使っているのですが、いつもDockerfileやdocker-composeの内容を忘れてしまうので、メモしておく。

Dockerfile
#go version
FROM golang:alpine

#update & install (vimやbashを入れとくと便利)
RUN apk add --update && apk add git && apk add vim && apk add bash

# 作業ディレクトリ作成
RUN mkdir /go/src/app

# 作業ディレクトリ設定
WORKDIR /go/src/app

# ホットリロード用にairをインストール
RUN go install github.com/air-verse/air@latest

# airを実行
CMD ["air"]
docker-compose.yml
version: '3.9'
services:
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - ./app:/go/src/app
    ports:
      - '8000:8000'
    tty: true

これで最低限開発はできるはず。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?