Add part3

This commit is contained in:
Andrew Trieu
2023-05-23 08:05:53 +03:00
parent 41757b9830
commit fa5d8255d6
1296 changed files with 167750 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
/.git
/node_modules
.dockerignore
.env
Dockerfile
fly.toml
<% if (remix) { -%>
/.cache
/build
/public/build
<% } -%>

View File

@@ -0,0 +1,94 @@
# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=<%= nodeVersion %>
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="<%= runtime %>"
# <%= runtime %> app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV=production
<% if (yarn && yarnVersion != yarnClassic) { -%>
ARG YARN_VERSION=<%= yarnVersion %>
<% if(yarnVersion.startsWith('3.')) {-%>
# Install Yarn 3
RUN corepack enable && \
yarn set version ${YARN_VERSION}
<% } else { -%>
RUN npm install -g yarn@$YARN_VERSION --force
<% } -%>
<% } else if (pnpm) { -%>
ARG PNPM_VERSION=<%= pnpmVersion %>
RUN npm install -g pnpm@$PNPM_VERSION
<% } %>
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y <%= python %> pkg-config build-essential <%
if (prisma) { %>openssl <% } %>
# Install node modules
COPY --link <%= packageFiles.join(' ') %> ./
RUN <%= packagerInstall %>
<% if (prisma) { -%>
# Generate Prisma Client
COPY --link prisma .
RUN npx prisma generate
<% } -%>
# Copy application code
COPY --link . .
<% if (build) { -%>
# Build application
RUN <%= packager %> run build
<% } -%>
<% if (devDependencies && !nestjs) { -%>
# Remove development dependencies
RUN <%= packagerPrune %>
<% } -%>
# Final stage for app image
FROM base
# Copy built application
COPY --from=build /app /app
<% if (false && !options.root) /* needs more testing */ { -%>
# Run as a non-root user for security
RUN addgroup --system --gid 1001 nodejs && \
useradd <%= user %> --gid nodejs --home /app --shell /bin/bash
USER <%= user %>:nodejs
<% } -%>
<% if (entrypoint) { -%>
<% if (entrypointFixups.length) { -%>
# Adjust entrypoint to be executable on Linux
RUN <%- entrypointFixups.join(' && \\\n ') %>
<% } -%>
<% if (prisma) { -%>
# Entrypoint prepares the database.
<% } else { -%>
# Entrypoint sets up the container.
<% } -%>
ENTRYPOINT [ "/app/docker-entrypoint" ]
<% } -%>
# Start the server by default, this can be overwritten at runtime
EXPOSE <%= port %>
<% if (nuxtjs) { -%>
ENV HOST=0
<% } -%>
CMD <%- JSON.stringify(startCommand, null, 1).replaceAll(/\n\s*/g, " ") %>

View File

@@ -0,0 +1,20 @@
#!/bin/bash -e
<% if (options.swap) { -%>
# allocate swap space
fallocate -l <%= options.swap %> /swapfile
chmod 0600 /swapfile
mkswap /swapfile
echo 10 > /proc/sys/vm/swappiness
swapon /swapfile
echo 1 > /proc/sys/vm/overcommit_memory
<% } -%>
<% if (prisma) { -%>
# If running the web server then migrate existing database
if [ "${*}" == "{{ .packager }} run start" ]; then
npx prisma migrate deploy
fi
<% } -%>
exec "${@}"