Last active
October 23, 2023 05:15
-
-
Save diegofcornejo/61ab4bcd090424a936de1a4c709c317d to your computer and use it in GitHub Desktop.
Dockerize: Build (Vite) React App inside Turborepo and serve on ASMTTPD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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