livebud / bud

The Full-Stack Web Framework for Go
MIT License
5.57k stars 180 forks source link

How to deploy Bud to Real-world ? #202

Open ghost opened 2 years ago

ghost commented 2 years ago

I want to deploy to ec2, or heroku. How can I do that ? (I'm newbie)

matthewmueller commented 2 years ago

Hey @gunnrcrakr, I'm working on documentation for this! Right now it'd be a bit manual:

  1. Launch an EC2 instance
  2. scp your code to that instance or build the binary locally in a linux docker container
  3. SSH into that instance
  4. Build the binary if you haven't already
  5. Start the binary
  6. Optionally setup systemd to restart the binary when the instance restarts or process crashes.
ghost commented 2 years ago

Hey @gunnrcrakr, I'm working on documentation for this! Right now it'd be a bit manual:

  1. Launch an EC2 instance
  2. scp your code to that instance or build the binary locally in a linux docker container
  3. SSH into that instance
  4. Build the binary if you haven't already
  5. Start the binary
  6. Optionally setup systemd to restart the binary when the instance restarts or process crashes.

Do I have to install livebud on that ec2 ?

jfmario commented 2 years ago

This is what I've been working with for running the bud app with docker:


FROM golang:1.18.4-buster

# install node & npm
RUN apt-get update
RUN apt-get install -y curl
RUN curl sL https://deb.nodesource.com/setup_16.x | bash
RUN apt-get install -y nodejs

# install bud
RUN curl -sf https://raw.githubusercontent.com/livebud/bud/main/install.sh | sh

# build your app
COPY . /app
WORKDIR /app

# will not work if you have the broken relative path in go.mod
RUN bud build

EXPOSE 3000
EXPOSE 35729

ENTRYPOINT ./bud/app --listen 0.0.0.0:3000 --log debug

# docker run -it -p 3000:3000 -p 35729:35729 <image-name>
inluxc commented 2 years ago

The best way is to build in a builder container and then copy to a scratch container just the build.

Then push to an docker registry so we can download the latest version. I will do an github action and gitlab ci and do an example repo.

Fuerback commented 1 year ago

Here is how I'm doing it @inluxc

FROM node:18-buster AS builder

COPY --from=golang:1.19-buster /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"

RUN curl -sf curl https://raw.githubusercontent.com/livebud/bud/main/install.sh | sh -s 0.2.8

WORKDIR /app

COPY . /app
RUN npm install
RUN go mod download
RUN bud build

FROM debian:buster-slim

RUN apt-get update && apt-get install -y ca-certificates openssl
ARG cert_location=/usr/local/share/ca-certificates
RUN update-ca-certificates

COPY --from=builder /app/bud/app /
COPY --from=builder /app/go.mod /

EXPOSE 3000

ENTRYPOINT ./app --listen 0.0.0.0:3000