Docker Advanced: Dockerfiles for Astro and Pocketbase on Railway

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


Here’s a super quick way to deploy Astro and PocketBase on Railway (referral link).

I used this Dockerfile to deploy PocketBase:

FROM ubuntu:latest

ARG PB_VERSION=0.20.4

# Install unzip and ca-certificates
RUN apt-get update && \
    apt-get install -y \
    unzip \
    ca-certificates && \
    rm -rf /var/lib/apt/lists/*

# download and unzip PocketBase
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
RUN unzip /tmp/pb.zip -d /pb/ && \
    rm /tmp/pb.zip

EXPOSE 8080

# start PocketBase
CMD ["/pb/pocketbase", "serve", "--http=0.0.0.0:8080"]

and this Dockerfile to deploy SSR Astro:

FROM node:lts-slim as runtime
WORKDIR /app

# Ensure that both node_modules and package-lock.json are removed.
COPY package.json .
RUN rm -rf node_modules package-lock.json

# Perform a fresh installation of npm dependencies.
RUN npm install

# Copy the rest of your application files.
COPY . .

# Build your application.
RUN npm run build

# Set environment variables and expose the appropriate port.
ENV HOST=0.0.0.0
ENV PORT=3000
EXPOSE 3000

# Define the command to run your application.
CMD node ./dist/server/entry.mjs

Avoiding Alpine Linux as the base image fixed an issue with internal links I had, so now the 2 instances can talk via *.railway.internal internal Railway URLs.

Lessons in this unit:

0: Introduction
1: Working with Images from the command line
2: Working with Containers from the command line
3: Troubleshooting container exits
4: How to commit changes to an image
5: Updating a deployed container
6: Accessing files outside a container
7: Dockerfile for Astro on Fly.io
8: ▶︎ Dockerfiles for Astro and Pocketbase on Railway