2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS educateのクレジットで新型コロナウイルスの感染者マップを作った(個人開発)

Last updated at Posted at 2020-02-26

完成物

新型コロナウイルス感染マップ

Screen Shot 2020-02-26 at 23.09.43.png

使用した技術

  • フロンエンド
    • React
    • Typescript
    • Nginx
  • バックエンド
    • Golang (Gin)
    • PostgreSQL
  • インフラ
    • AWS (EC2, S3, Route53)
    • Docker (Compose)
  • API
    • Twitter

インフラコスト

学生であればAWS educateに登録すれば**$40**のクレジットがもらえます。無料利用期間であれば、EC2のt2microインスタンスであれば約一ヶ月間は無料で起動できます。またRDSに関しても同様に一ヶ月無料で利用可能です。今回、課金したのはRoute53で購入したドメイン名($13/year)とhttps化のためのALBの利用のみです(nginx側でLet's Encryptでやってもいいと思います)。

↓ AWS Account(赤枠)ってところからいけます。
Screen Shot 2020-02-26 at 23.36.14.png

関係ないですけど、Github Student Packも学生なら無料でたくさんのサービスが使えてすごいです!

デプロイ

デプロイはECSを試したんですが、うまくいかなかったので、全然スマートではないですが、EC2にDockerいれて、Git pullして、docker-compose upで終わらせました。

Dockerfileはフロント、バックエンドそれぞれこんな感じです。

開発環境

バンクエンド (Golang)


# build stage
FROM golang:latest
WORKDIR /go/src/app
COPY . .
RUN go get -d -v ./...

EXPOSE 8080

本番環境

フロント (React + Typescript -> Nginx) 

FROM node:12 as builder

WORKDIR /coronamap_japan_front
ADD . .
ENV NODE_ENV=production
RUN yarn install
RUN yarn build

FROM nginx:1.16.0-alpine
COPY --from=builder /coronamap_japan_front/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
ADD  nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]  
  • node-prune(使ってない.js, .tsのモジュールを消してくれるやつ)使う予定でしたが,yarn buildしたときにTypescriptのエラーが出てしまい断念しました。。。

バンクエンド (Golang)


# build stage
FROM golang:alpine AS builder
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go get -d -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /main .

# final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /main .
RUN chmod +x ./main
LABEL Name=coronamap_japan Version=0.0.1
ENTRYPOINT [ "./main" ]
EXPOSE 8080

サーバー落ちないように頑張ります。

2
1
1

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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?