Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add experimental docker setup command #9024

Merged
merged 4 commits into from
Oct 6, 2023

Conversation

jtoar
Copy link
Contributor

@jtoar jtoar commented Aug 8, 2023

Adds an experimental setup command to add a Dockerfile and compose files:

yarn rw exp setup-docker

The Dockerfile is near enough complete that we should release it experimentally so that we can get feedback from the community. I've successfully deployed it to Coherence and Fly. As far as I can tell, Render has half support. The api side runs just fine, but the web side has a static runtime, and I'm not sure how to get it to take the files from the web build stage.

There's a known sticking point here: seeding and data migrations. I understand the problem clearly now. On all providers, seed and data migrations run using the image built from targeting api serve. There's only production dependencies in that image—yarn rw exec won't work for a number of reasons, but the main one is that @redwoodjs/internal isn't around. It's looking like we'll have to move yarn rw exec into it's own package and that we'll have to finish #8572.

The docs are there but are very much a WIP.

@jtoar jtoar added the release:feature This PR introduces a new feature label Aug 8, 2023
@jtoar jtoar added this to the next-release milestone Aug 8, 2023

import { getEpilogue } from './util'

export const EXPERIMENTAL_TOPIC_ID = null
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to replace this when I make a post on the forums

Comment on lines 19 to 24
.option('verbose', {
alias: 'v',
default: false,
description: 'Print more logs',
type: 'boolean',
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't used this flag for anything yet

Comment on lines 44 to 85
{
title: 'Adding the experimental Dockerfile...',
task: () => {
const dockerfileTemplateContent = fs.readFileSync(
path.resolve(__dirname, 'templates', 'docker', 'Dockerfile'),
'utf-8'
)

return [
writeFile(dockerfilePath, dockerfileTemplateContent, {
overwriteExisting: force,
}),
]
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: think about collapsing these writeFile tasks into one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs more comments explaining what's going on


services:
redwood:
user: node
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-Walker-GM do we need to specify user here? We don't in the prod compose

@jtoar jtoar modified the milestones: next-release, v6.1.0 Aug 12, 2023
@jtoar jtoar modified the milestones: next-release, v6.2.0 Sep 2, 2023
@thedavidprice
Copy link
Contributor

@jtoar to use yarn workspaces focus you'll need to run yarn plugin import workspace-tools either in the project or in the Dockerfile (correct?).

Copy link
Contributor Author

jtoar commented Sep 6, 2023

yes that's right

@xmaxcooking
Copy link
Contributor

xmaxcooking commented Sep 14, 2023

The compose-dev works very smooth but I've run into some issues with the compose-prod.

  • The web and the api are missing the dependency @redwoodjs/api-server. This should be either added on setup experimental setup-docker or noted in the readme

  • The api ignores the server.config.js

  • The web_serve has access to ENV vars but it doesn't pass them to the base target and web building. The running containers will have no ENV vars from the necessary includeEnvironmentVariables if built like this.

It's still possible to have them if you add a line to the Dockerfile at the end of the base target.

ARG CLERK_PUBLISHABLE_KEY && ENV CLERK_PUBLISHABLE_KEY=${CLERK_PUBLISHABLE_KEY}

and pass them in the docker-compose like this:

  web:
    build:
      context: .
      dockerfile: ./Dockerfile
      target: web_serve
      args:
        CLERK_PUBLISHABLE_KEY: placeholder

instead of like this:

  web:
    build:
      context: .
      dockerfile: ./Dockerfile
      target: web_serve
    environment: 
      CLERK_PUBLISHABLE_KEY: placeholder

It might be good to add this to the readme and save a few headaches.

@jtoar
Copy link
Contributor Author

jtoar commented Sep 16, 2023

thanks for the feedback @xmaxcooking i really appreciate it! i was out last week and was getting caught up this week, fixing a few bugs. i'll turn my focus back to this now

@jtoar jtoar modified the milestones: next-release, v6.3.0 Sep 16, 2023
@jtoar jtoar force-pushed the ds-docker/add-exp-setup-command branch 4 times, most recently from 1852e4f to f838940 Compare September 22, 2023 02:57
@jtoar jtoar force-pushed the ds-docker/add-exp-setup-command branch from f838940 to 230e72c Compare October 6, 2023 03:01
@jtoar jtoar marked this pull request as ready for review October 6, 2023 03:01
@jtoar jtoar merged commit 08a6720 into main Oct 6, 2023
32 checks passed
@jtoar jtoar deleted the ds-docker/add-exp-setup-command branch October 6, 2023 03:51
jtoar added a commit that referenced this pull request Oct 8, 2023
Adds an experimental setup command to add a Dockerfile and compose
files:

```
yarn rw exp setup-docker
```

The Dockerfile is near enough complete that we should release it
experimentally so that we can get feedback from the community. I've
successfully deployed it to Coherence and Fly. As far as I can tell,
Render has half support. The api side runs just fine, but the web side
has a static runtime, and I'm not sure how to get it to take the files
from the web build stage.

There's a known sticking point here: seeding and data migrations. I
understand the problem clearly now. On all providers, seed and data
migrations run using the image built from targeting api serve. There's
only production dependencies in that image—`yarn rw exec` won't work for
a number of reasons, but the main one is that `@redwoodjs/internal`
isn't around. It's looking like we'll have to move `yarn rw exec` into
it's own package and that we'll have to finish
#8572.

The docs are there but are very much a WIP.
@jtoar jtoar modified the milestones: next-release, v6.4.0 Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:feature This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants