You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a small app which connects to my AWS Postgres database to perform a few selects. This works fine on my Intel Mac mini macOS (14.5 23F79). However, it crashes towards the end when ran inside an Alpine Docker container.
Reproduction Steps
importosimporttimeimportdb.pgconstpg_host= os.getenv_opt('DATABASE_HOST') or { panic('DATABASE_HOST not found') }
constpg_user= os.getenv_opt('DATABASE_USER') or { panic('DATABASE_USER not found') }
constpg_pass= os.getenv_opt('DATABASE_PASSWORD') or { panic('DATABASE_PASSWORD not found') }
constpg_db= os.getenv_opt('DATABASE_NAME') or { panic('DATABASE_NAME not found') }
@[table: 'authors']
structAuthor {
id int @[primary; sql: serial]
name string @[sql_type: 'VARCHAR(65)']
email string @[sql_type: 'VARCHAR(65)']
social_twitter ?string @[sql_type: 'VARCHAR(65)']
social_facebook ?string @[sql_type: 'VARCHAR(65)']
social_instagram ?string @[sql_type: 'VARCHAR(65)']
social_youtube ?string @[sql_type: 'VARCHAR(65)']
social_pinterest ?string @[sql_type: 'VARCHAR(65)']
social_linkedin ?string @[sql_type: 'VARCHAR(65)']
social_stackoverflow ?string @[sql_type: 'VARCHAR(65)']
social_gitlab ?string @[sql_type: 'VARCHAR(65)']
}
@[table: 'books']
structBook {
id int @[primary; sql: serial]
slug ?string @[sql_type: 'VARCHAR(200)']
category ?string @[sql_type: 'VARCHAR(25)']
asin ?string @[sql_type: 'VARCHAR(10)']
title string @[sql_type: 'VARCHAR(200)']
product_url ?string @[sql_type: 'VARCHAR(200)']
image_url ?string @[sql_type: 'VARCHAR(200)']
publication_date string @[sql_type: 'DATE']
review ?string @[sql_type: 'TEXT']
created_at string @[default: 'CURRENT_TIMESTAMP'; sql_type: 'TIMESTAMP']
goodreads_url ?string @[sql_type: 'VARCHAR(200)']
}
@[table: 'posts']
structPost {
id int @[primary; sql: serial]
author_id int @[fkey: 'parent_id']
slug string @[sql_type: 'VARCHAR(256)']
title string @[sql_type: 'VARCHAR(256)']
summary ?string @[sql_type: 'VARCHAR(256)']
categories ?string// Is _text supported?
tags ?string// Is _text supported?
status string @[sql_type: 'VARCHAR(15)']
view_count ?int @[default: 0]
content_type ?string @[sql_type: 'VARCHAR(15)']
content_path ?string @[sql_type: 'VARCHAR(256)']
created_at ?time.Time @[default: 'CURRENT_TIMESTAMP'; sql_type: 'TIMESTAMP']
updated_at ?time.Time @[sql_type: 'TIMESTAMP']
published_at ?time.Time @[sql_type: 'TIMESTAMP']
last_view_at ?time.Time @[sql_type: 'TIMESTAMP']
}
db:= pg.connect(host: pg_host, user: pg_user, password: pg_pass, dbname: pg_db)!authors_count:= sql db {
select count from Author
}!println('number of all authors: ${authors_count}')
books_count:= sql db {
select count from Book
}!println('number of all books: ${books_count}')
scifi_books_count:= sql db {
select count from Book where category=='science fiction'
}!println('number of sci-fi books: ${scifi_books_count}')
posts_count:= sql db {
select count from Post
}!println('number of all posts: ${posts_count}')
published_posts_count:= sql db {
select count from Post where published_at !isnone
}!println('number of all published posts: ${published_posts_count}')
diy_books_count:= sql db {
select count from Book where category=='diy'
}!println('number of diy books: ${diy_books_count}')
diy_books:= sql db {
select from Book where category=='diy'
}!println('\nDIY books:\n')
for book in diy_books {
println('${book.id}:\t${book.title}')
}
Expected Behavior
On macOS:
$ dotenv -o -f ".env.heroku" v run src/main.vnumber of all authors: 1number of all books: 321number of sci-fi books: 16number of all posts: 141number of all published posts: 141number of diy books: 5DIY books:73: Treehouses and other Cool Stuff: 50 Projects You Can Build90: Handy Dad: 25 Awesome Projects for Dads and Kids91: Geek Dad: Awesomely Geeky Projects and Activities for Dads and Kids to Share126: The Handbuilt Home: 34 Simple Stylish and Budget-Friendly Woodworking Projects for Every Room151: The Furniture Bible: Everything You Need to Know to Identify, Restore & Care for Furniture
Current Behavior
On Alpine Docker container:
podman run --env-file ".env.heroku" --rm -it v-postgresnumber of all authors: 1number of all books: 321number of sci-fi books: 16number of all posts: 141number of all published posts: 141number of diy books: 5signal 11: segmentation faultbacktrace_symbols is missing => printing backtraces is not available.Some libc implementations like musl simply do not provide it.make: *** [podmanRun] Error 139
Possible Solution
I'm not sure what is causing the fault on Alpine, though it occurs somewhere in the last bit of code:
diy_books:= sql db {
select from Book where category=='diy'
}!println('\nDIY books:\n')
for book in diy_books {
println('${book.id}:\t${book.title}')
}
Additional Information/Context
Dockerfile:
# Stage 1: Build the V applicationFROM thevlang/vlang:latest AS builder
# Install necessary packages for PostgreSQLRUN apk add --no-cache postgresql-dev
# Set the working directoryWORKDIR /app
# Copy the source code into the containerCOPY . .
# Build the V projectRUN v -o app src/main.v
# Stage 2: Create a smaller image with the executableFROM alpine:latest
# Install necessary packages to run the application with PostgreSQLRUN apk add --no-cache libpq
ARG DATABASE_HOST
ARG DATABASE_PORT
ARG DATABASE_NAME
ARG DATABASE_USER
ARG DATABASE_PASSWORD
ENV DATABASE_HOST $DATABASE_HOST
ENV DATABASE_PORT $DATABASE_PORT
ENV DATABASE_NAME $DATABASE_NAME
ENV DATABASE_USER $DATABASE_USER
ENV DATABASE_PASSWORD $DATABASE_PASSWORD
# Set the working directoryWORKDIR /app
# Copy the executable from the builder stageCOPY --from=builder /app/app /app/
# Run the V applicationCMD ["./app"]
I added code to print the V version when the app runs.
importv.util.versionprintln(version.v_version)
If I run it locally on macOS I get the current version; even tried this with the new 0.4.7 version.
However, while running from the Docker container (thevlang/vlang:latest builder / alpine:latest runner) the version prints as 0.4.3. Does this mean the thevlang/vlang:latest Docker image is out-of-date?
Describe the bug
I wrote a small app which connects to my AWS Postgres database to perform a few selects. This works fine on my Intel Mac mini macOS (14.5 23F79). However, it crashes towards the end when ran inside an Alpine Docker container.
Reproduction Steps
Expected Behavior
On macOS:
Current Behavior
On Alpine Docker container:
Possible Solution
I'm not sure what is causing the fault on Alpine, though it occurs somewhere in the last bit of code:
Additional Information/Context
Dockerfile:
V version
0.4.6 4a7c70c
Environment details (OS name and version, etc.)
Alpine:latest
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: