0 to 100 on AWS – Building a full stack web mapping application with PostGIS, GeoServer, OpenLayers and ReactJS
We can now package our application for deployment, and use S3 to serve it as a static website.
From the top-level directory of your foss4g-client
app, run the following command.
npm run build
This will compile and minify our application down to a handful of HTML, JS and
CSS files. Once the build process completes, look in the build
directory to
see what was produced. You should see the following directory structure:
|-- build
| |-- static
| | |-- css
| | |-- js
Now, we can set up an S3 bucket to serve the website:
- Log in to the AWS console
- Go to the S3 service
- Select Create bucket
- Enter a name for the bucket and select Next. An S3 bucket name must be a valid DNS segment and must be globally unique.
- Add tags to the bucket if you wish, and select Next.
- Under Manage public permissions, select "Grant public read access to this bucket" from the drop list and then Next.
- Select Create bucket.
- Select your new bucket from the list.
- Choose the Properties tab.
- Click on Static website hosting.
- Select "Use this bucket to host a website".
- Under Index document, enter
index.html
and Save.
We now have a publically viewable S3 bucket which can serve a static website.
Next, we'll upload our build files to the bucket. If you're comfortable using
the AWS CLI, you can use a aws s3 sync
command to recursively upload the
contents of the build directory to the bucket. To upload the files manually
via the web console, proceed as follows:
- Return to the Overview tab of your S3 bucket.
- Select Upload and drag and drop the contents of the build directory into the Upload dialog and then click Next.
- In the Set permissions dialog under Manage public permissions select "Grant public read access to this object(s).
- Click Upload
Our web application should now be ready to use. Return to the bucket root folder, select the Properties tab and click on Static website hosting. Click on the endpoint link to visit your new website.
Congratulations, you've just gone from 0 to 100 on AWS and built a full-stack web mapping application!
Previous: 7.3. Finish app | Up: Index | Next: 8. Cleanup