# Dockerfiles used to deploy Astro and PocketBase on Railway

> The two Dockerfiles I used to deploy Astro and PocketBase on Railway, and why avoiding Alpine Linux fixed internal networking between the services.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2024-01-04 | Topics: [Docker](https://flaviocopes.com/tags/docker/), [Services](https://flaviocopes.com/tags/services/) | Canonical: https://flaviocopes.com/dockerfiles-used-to-deploy-astro-and-pocketbase-on-railway/

Here's a super quick way to deploy [Astro](https://flaviocopes.com/astro-introduction/) and PocketBase on [Railway](https://railway.app?referralCode=kqLGRd) (referral link).

I used this Dockerfile to deploy PocketBase:

```docker
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:

```docker
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](https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images), so now the 2 instances can talk via `*.railway.internal` internal Railway URLs.

If you need a Dockerfile for a different setup, I made a free [Dockerfile generator](https://flaviocopes.com/tools/dockerfile-generator/) that covers Node.js, Next.js, Astro, Bun and static sites.
