diff --git a/.github/workflows/deploy-prod.yaml b/.github/workflows/deploy-prod.yaml index 1a89d63..5920955 100644 --- a/.github/workflows/deploy-prod.yaml +++ b/.github/workflows/deploy-prod.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config strapi/fly.production.toml + - run: flyctl deploy --remote-only --config strapi/fly.production.toml --dockerfile strapi/Dockerfile.production env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI }} deploy-frontend: @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config frontend/fly.production.toml + - run: flyctl deploy --remote-only --config frontend/fly.production.toml --dockerfile frontend/Dockerfile.production env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND }} deploy-storage: @@ -30,6 +30,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config storage/fly.production.toml + - run: flyctl deploy --remote-only --config storage/fly.production.toml --dockerfile storage/Dockerfile.production env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE }} diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 9d8ec09..8058bd7 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config strapi/fly.staging.toml + - run: flyctl deploy --remote-only --config strapi/fly.staging.toml --dockerfile strapi/Dockerfile.staging env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI_STAGING }} deploy-frontend: @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config frontend/fly.staging.toml + - run: flyctl deploy --remote-only --config frontend/fly.staging.toml --dockerfile frontend/Dockerfile.staging env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND_STAGING }} deploy-storage: @@ -30,6 +30,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: superfly/flyctl-actions/setup-flyctl@master - - run: flyctl deploy --remote-only --config storage/fly.staging.toml + - run: flyctl deploy --remote-only --config storage/fly.staging.toml --dockerfile storage/Dockerfile.staging env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE_STAGING }} diff --git a/frontend/Dockerfile b/frontend/Dockerfile.production similarity index 100% rename from frontend/Dockerfile rename to frontend/Dockerfile.production diff --git a/frontend/Dockerfile.staging b/frontend/Dockerfile.staging new file mode 100644 index 0000000..a345b59 --- /dev/null +++ b/frontend/Dockerfile.staging @@ -0,0 +1,49 @@ +# syntax = docker/dockerfile:1 + +# Adjust NODE_VERSION as desired +ARG NODE_VERSION=20.0.0 +FROM node:${NODE_VERSION}-slim as base + +LABEL fly_launch_runtime="Next.js" + +# Next.js app lives here +WORKDIR /app + +# Set production environment +ENV NODE_ENV="production" + +# Install pnpm +ARG PNPM_VERSION=8.3.1 +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 --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 + +# Install node modules +COPY --link .npmrc package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile --prod=false + +# Copy application code +COPY --link . . + +# Build application +RUN pnpm run build + +# Remove development dependencies +RUN pnpm prune --prod + + +# Final stage for app image +FROM base + +# Copy built application +COPY --from=build /app /app + +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +CMD [ "pnpm", "run", "start" ] diff --git a/strapi/Dockerfile.production b/strapi/Dockerfile.production new file mode 100644 index 0000000..d5f99ee --- /dev/null +++ b/strapi/Dockerfile.production @@ -0,0 +1,35 @@ + + +# 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 --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3 + +# Install node modules +COPY --link .npmrc package.json yarn.lock ./ +RUN yarn install --frozen-lockfile --prod=false + +# Copy application code +COPY --link . . + +# Build application +RUN yarn run build + +# Remove development dependencies +# RUN yarn prune --prod + +# Final stage for app image +FROM base + +# Copy built application +COPY --from=build /app /app + +# Setup sqlite3 on a separate volume +RUN mkdir -p /data +VOLUME /data + +# Start the server by default, this can be overwritten at runtime +EXPOSE 1337 +CMD [ "yarn", "run", "start" ] diff --git a/strapi/Dockerfile b/strapi/Dockerfile.staging similarity index 100% rename from strapi/Dockerfile rename to strapi/Dockerfile.staging