Skip to content

Instantly share code, notes, and snippets.

@diegofcornejo
Last active October 23, 2023 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegofcornejo/61ab4bcd090424a936de1a4c709c317d to your computer and use it in GitHub Desktop.
Save diegofcornejo/61ab4bcd090424a936de1a4c709c317d to your computer and use it in GitHub Desktop.
Dockerize: Build (Vite) React App inside Turborepo and serve on ASMTTPD
# Base image
FROM alpine:3.18.4 as base
RUN apk update && apk upgrade
RUN apk add --no-cache make yasm binutils git nodejs npm
RUN npm install -g yarn
# Compile asmttpd http server
from base as build-asmttpd
RUN git clone --depth 1 https://github.com/nemasu/asmttpd
WORKDIR /asmttpd
RUN make release
RUN chmod +x asmttpd
# Build vite stage
from base as build-vite
# Copy whole project
COPY ../../ .
# Install dependencies
RUN yarn install
# Build app
RUN yarn workspace myapp build
# Production stage
FROM scratch as production
# Copy asmttpd binary from build-asmttpd stage
COPY --from=build-asmttpd /asmttpd/asmttpd /asmttpd
# Copy build artifacts from build-vite stage
COPY --from=build-vite /apps/myapp/dist /web_root
EXPOSE 80
CMD ["/asmttpd", "/web_root", "80"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment